Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

order by - sorting 1

Status
Not open for further replies.

puitar

Programmer
Apr 8, 2001
64
AU
Hello,

I have a sql statement..

select * from Properties where PropertyType = 'Land' order by 'TotalPrice'

The client wants to display certain records first eg (where agent = 'HeadOffice') and then display the rest.

Can this be done with sql or do I have to do it with two seperate queries?

Thanks
 
This should help. I assume TotalPrice is a column name - remove the quotes, otherwise it will be treated as a string value.

Code:
select * from Properties where PropertyType = 'Land'
 order by case when agent = 'HeadOffice' THEN 0 ELSE 1 END,  TotalPrice
 
Thanks SonOfEmidec1100

Works a treat :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top