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 |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-01-05 : 09:24:38
|
| I would like to have the dates in order to appear in my dropdown.Here's the data in the DB and how it appears in the dropdown. 12/25/0912/18/0912/11/0901/01/10How can I get 01/01/10 to appear on top of the list and the rest in desc order?This isn't working for me:SELECT CONVERT(VARCHAR, WKDate, 1) AS [Week]FROM TSRPTotalsGROUP BY CONVERT(VARCHAR, WKDate, 1)ORDER BY Week DESC |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-05 : 09:30:57
|
| ORDER BY WKDate DESCMadhivananFailing to plan is Planning to fail |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-01-05 : 09:42:17
|
| Tried that now I'm getting:Column "TSRPTotals.WKDate" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.SELECT CONVERT(VARCHAR, WKDate, 1) AS [Week]FROM TSRPTotalsGROUP BY CONVERT(VARCHAR, WKDate, 1)ORDER BY WKDate DESC |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-01-05 : 09:45:31
|
| Never mind I got this to work:SELECT CONVERT(VARCHAR, WKDate, 1) AS [Week]FROM TSRPTotalsGROUP BY WKDateORDER BY WKDate DESCThanks for your help! |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-06 : 03:17:48
|
quote: Originally posted by JJ297 Never mind I got this to work:SELECT CONVERT(VARCHAR, WKDate, 1) AS [Week]FROM TSRPTotalsGROUP BY WKDateORDER BY WKDate DESCThanks for your help!
why are you applying group by? is your attempt to get distinct date values? |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-01-06 : 03:25:40
|
quote: Originally posted by visakh16
quote: Originally posted by JJ297 Never mind I got this to work:SELECT CONVERT(VARCHAR, WKDate, 1) AS [Week]FROM TSRPTotalsGROUP BY WKDateORDER BY WKDate DESCThanks for your help!
why are you applying group by? is your attempt to get distinct date values?
Yes. I think soMadhivananFailing to plan is Planning to fail |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2010-01-06 : 13:30:40
|
| Sorry for the late reply...yes it is to get the distinct values. Thanks! |
 |
|
|
|
|
|
|
|