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
 SQL Server Development (2000)
 group then order

Author  Topic 

andrewcw
Posting Yak Master

133 Posts

Posted - 2005-06-02 : 20:46:19
I have a data that I need to sum by group and then order.

eg. SELECT Customer, SUM(Elapsedsecs) AS SystemTime
FROM dbo.TestBlockStatusTest
WHERE (SystemName = 'foo')
GROUP BY Customer

OK Now I need to order the above....

This wont work:
Select * from
( SELECT Customer, SUM(Elapsedsecs) AS SystemTime FROM dbo.TestBlockStatusTest
WHERE SystemName = 'foo' GROUP BY Customer )
order by SystemTime

Thanks !!!

andrewcw

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2005-06-02 : 20:53:12
SELECT Customer, SUM(Elapsedsecs) AS SystemTime
FROM dbo.TestBlockStatusTest
WHERE (SystemName = 'foo')
GROUP BY Customer
ORDER BY SUM(ElapsedSecs)

?



Damian
Ita erat quando hic adveni.
Go to Top of Page

andrewcw
Posting Yak Master

133 Posts

Posted - 2005-06-02 : 21:02:01
Thats what I needed ! That was quick you all are great !

andrewcw
Go to Top of Page
   

- Advertisement -