Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
landau66
Yak Posting Veteran
61 Posts |
Posted - 2014-01-31 : 09:47:44
|
Hi everyone,I try to make the following:select DATENAME(WEEKDAY,[date]) as DAY, sum(earnings) as Earningsfrom myTablewhere DATENAME(WEEKDAY,[date]in ('monday','tuesday','wednesday','thursday','friday')group by DATENAME(WEEKDAY,[date])order by DAYthis query works very well except the last line. the last line causes SQL-Server to order the days in an alphabetical order.What do I have to do that SQL-Server orders the days according to their natural appearance (monday, tuesday, wednesday, thurs......)Thank you very much in advanceLandau |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2014-01-31 : 13:23:50
|
[code]order by case datename(weekday, [date]) when 'Monday' then 1 when 'Tuesday' then 2 when 'Wednesday' then 3 when 'Thursday' then 4 when 'Friday' then 5 end[/code]===============================================================================There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber (1894-1961) |
 |
|
landau66
Yak Posting Veteran
61 Posts |
Posted - 2014-01-31 : 17:14:32
|
thanks a lot bustaz!it works exactly I wanted it to work.greetingslandau |
 |
|
|
|
|
|
|