Jump to content

How to order by weekday (but not alphabetically!) ?


timcclayton

Recommended Posts

Hello all.
I am using a SELECT query to drag out records sorted by WEEKDAY. The trouble is, they sort themselves alphabetically (naturally) and this looks a bit stupid when Friday is the "first" day. Is there a way to sort by actual weekday order?

Code I am using is:

[code]"SELECT * FROM FLIGHTS ORDER BY 'intdom', 'day' ASC"[/code]

where "day" is the weekday field.
[code]"SELECT * FROM FLIGHTS ORDER BY intdom,
CASE
WHEN day='Sunday' THEN 0
WHEN day='Monday' THEN 1
WHEN day='Tuesday' THEN 2
WHEN day='Wednesday' THEN 3
WHEN day='Thursday' THEN 4
WHEN day='Friday' THEN 5
WHEN day='Saturday' THEN 6
END"[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.