Login    Forum    Search    FAQ   Blog

Board index » Server Side Development » SQL




 Page 1 of 1 [ 4 posts ] 



Author Message
 Post subject: Orderin the custom columns'
 Post Posted: Thu Nov 19, 2009 6:58 am 
Offline

Joined: Sat Feb 21, 2009 1:04 pm
Posts: 47
Hi,

I m havin a query like this;

Code:
SELECT COMPANY_NAME,ADDRESS,ZIPCODE,
CASE WHEN COM_TYPE = 0 THEN 'Seller'
WHEN COM_TYPE = 1 THEN 'Buyer' AS COMPANY_TYPE
FROM COMPANIES


My ques was , how could i order rows accordin 2 the
COMPANY_TYPE. When i have used the "ORDER BY COMPANY_TYPE ASC" sql
server says there was no column in da tab wid dis name! It was a
logical couse i created it in the query. Is there a way to sort these
type of columns with t-sql?


Top 
 Post subject: Re: Orderin the custom columns'
 Post Posted: Thu Nov 19, 2009 6:58 am 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
Try:
Code:

CASE WHEN COM_TYPE = 0 THEN 'Seller'
WHEN COM_TYPE = 1 THEN 'Buyer' END AS COMPANY_TYPE


otherwise, which Version r u runnin ? Or the Compatibility Level?
Or is da error referin 2 'com_Type'?


Top 
 Post subject: Re: Orderin the custom columns'
 Post Posted: Thu Nov 19, 2009 6:58 am 
Offline

Joined: Sat Feb 21, 2009 1:04 pm
Posts: 47
Oops..you r right!!!

Not sure why I have gave that...It should work dat way!!


Top 
 Post subject: Re: Orderin the custom columns'
 Post Posted: Thu Nov 19, 2009 6:58 am 
Offline

Joined: Sat Feb 21, 2009 11:06 am
Posts: 1794
:D


Top 
Display posts from previous:  Sort by  
 
 Page 1 of 1 [ 4 posts ] 




Board index » Server Side Development » SQL


Who is online

Users browsing this forum: No registered users and 1 guest

 
 

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron