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 2000 Forums
 Transact-SQL (2000)
 order by

Author  Topic 

jung1975
Aged Yak Warrior

503 Posts

Posted - 2005-05-10 : 17:26:44
I have a table looks like:
 
Time count
1AM 13
1PM 313
2AM 110
2PM 59
12AM 24
12PM 460


I would like to order by ..

Time count
1AM 13
2AM 313
12AM 110
1PM 59
2PM 24
12PM 460

How can I do this?

I've tried something like: order by substring([time], 1,2) asc, substring([time], 3,4) asc
,but it didn't work


AndyB13
Aged Yak Warrior

583 Posts

Posted - 2005-05-10 : 17:37:45
Are you sure about your order - 12AM comes before 1AM same goes for PM

You could do
ORDER BY CONVERT(datetime,[Time])

But this will output like this
12AM  24
1AM 13
2AM 110
12PM 460
1PM 313
2PM 59


Andy



Beauty is in the eyes of the beerholder
Go to Top of Page
   

- Advertisement -