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)
 ORDER BY

Author  Topic 

inbs
Aged Yak Warrior

860 Posts

Posted - 2009-05-19 : 12:21:01
i have a table like :

ColumnA    ColumnB Price
Red B 20
Red A 10
Red C 20
Green C 20
Green A 10
i want in SELECT to grt:

ColumnA    ColumnB Price
Red A 10
Red B 20
Red C 20
Green A 10
Green C 20

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-05-19 : 12:28:46
Order by ColumnB, ColumnA
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-05-19 : 12:50:44
Close: ORDER BY ColumnA DESC, ColumnB
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-05-19 : 13:11:50
[code]
SELECT columns...
FROM
(
SELECT ROW_NUMBER() OVER(PARTITION BY ColumnA ORDER BY ColumnB,Price) AS Seq,*
FROM YourTable
)t
ORDER BY Seq
[/code]
Go to Top of Page
   

- Advertisement -