sortedsites — 2012-09-03T09:14:45-04:00 — #1
I have the following query
SELECT [eventid], [name],[date] FROM events WHERE eventid IN(22,13,18)
I'd like to ensure the records are returned sorted by the eventid in the order the eventid's appear in the IN statement.
22 | Event ABC | 28/09/2012
13 | Event XYZ | 12/08/2012
18 | Event CDE | 22/09/2012
Is this possible?
r937 — 2012-09-03T09:37:10-04:00 — #2
BY CASE WHEN eventid = 22 THEN 'curly
WHEN eventid = 13 THEN 'larry'
sortedsites — 2012-09-03T09:44:16-04:00 — #3
Thanks Rudy, and I should have probably made this clear in my original post, is that valid for Access SQL or is some bizarre syntax required?
sortedsites — 2012-09-03T09:49:47-04:00 — #4
Scratch that I think I have it!
SELECT eventid,[name],[date] FROM events WHERE eventid IN(22,18,13) ORDER BY IIF(eventid = 22,'curly',IIF(eventid = 13, 'larry','moe'))
r937 — 2012-09-03T10:18:40-04:00 — #5
ace! (you got it in one)
p.s. if you add a 4th event id, you can use 'shemp' -- but after that, curly joe and joe would be out of sequence
sortedsites — 2012-09-03T10:45:32-04:00 — #6
Thanks, fortunately I only need to go to 3.
mittineague — 2014-09-18T22:57:10-04:00 — #7
This topic is now archived. It is frozen and cannot be changed in any way.