answermyquery.com
http://www.answermyquery.com/

Orderin the custom columns'
http://www.answermyquery.com/viewtopic.php?f=7&t=2417
Page 1 of 1

Author:  kylie [ Thu Nov 19, 2009 6:58 am ]
Post subject:  Orderin the custom columns'

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?

Author:  kranthi reddy [ Thu Nov 19, 2009 6:58 am ]
Post subject:  Re: Orderin the custom columns'

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'?

Author:  kylie [ Thu Nov 19, 2009 6:58 am ]
Post subject:  Re: Orderin the custom columns'

Oops..you r right!!!

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

Author:  kranthi reddy [ Thu Nov 19, 2009 6:58 am ]
Post subject:  Re: Orderin the custom columns'

:D

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/