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 2008 Forums
 Transact-SQL (2008)
 How to select data in below order?

Author  Topic 

itnagaraj
Yak Posting Veteran

70 Posts

Posted - 2013-01-29 : 02:26:48
The data should stroed in below order.
FormatId FormatDescription
1 Full Proposal w/Purchase Agreement
2 Short Proposal/Purchase Agreement
3 Purchase Agreement
4 Other
5 Test data
6 NA

But i would need to select the data in below format.

Alphabetical order First and "other" and "NA" should be at the end of the list.

V.NAGARAJAN

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-29 : 02:48:29
[code]
SELECT *
FROM Table
ORDER BY CASE FormatDescription
WHEN 'Other' THEN 1
WHEN 'N/A' THEN 2
ELSE 0
END ASC,FormatDescription ASC
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
Go to Top of Page

itnagaraj
Yak Posting Veteran

70 Posts

Posted - 2013-01-29 : 03:01:10
It will work. Thanks for your help.
quote:
Originally posted by visakh16


SELECT *
FROM Table
ORDER BY CASE FormatDescription
WHEN 'Other' THEN 1
WHEN 'N/A' THEN 2
ELSE 0
END ASC,FormatDescription ASC


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/




V.NAGARAJAN
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-29 : 03:06:08
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -