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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Problems with ORDER BY

Author  Topic 

dmaxj
Posting Yak Master

174 Posts

Posted - 2008-12-09 : 12:49:16
My query:

SELECT CONVERT(VARCHAR(10),eventDate,110) AS EventDate,
event AS EventName,
COUNT(eventDate) AS Event_Count
FROM Baseline2008
WHERE eventDate >= '04-01-2008' --Dates greater than April 1 2008
GROUP BY EventDate ASC, event


I am trying to get my result set to go from earliest EventDate to lastest. I keep getting 'Incorrect syntax near keyword 'ASC''.

When I remove ASC from the last line of code, I get a result set ; the problem is that the list is ordered by the EventName and not the EventDate.


visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-09 : 12:51:43
[code]SELECT CONVERT(VARCHAR(10),eventDate,110) AS DisplayEventDate,
event AS EventName,
COUNT(eventDate) AS Event_Count
FROM Baseline2008
WHERE eventDate >= '04-01-2008' --Dates greater than April 1 2008
GROUP BY eventDate, event
ORDER BY eventDate ASC
[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-09 : 12:52:59
just noticed you're grouyping by eventdate and then taking count of it. this will always return 1. is it really what you want?
Go to Top of Page

dmaxj
Posting Yak Master

174 Posts

Posted - 2008-12-09 : 12:59:49
Yes! Thanks a 1,000,000!!!

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-09 : 13:06:06
welcome
Go to Top of Page
   

- Advertisement -