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)
 Column Values Should come specified Order

Author  Topic 

kond.mohan
Posting Yak Master

213 Posts

Posted - 2015-04-02 : 03:51:00
Hi
i have table column in below manner
select relation from table1 output is below format
Relation
Mother
father
daughter
Wife
Son-in law
select relation from table1 order by table1
relation
dauhter
father
moher
son-in-law
Wife
my Requirement is we need to specify the order by column values

Is there way to make the column values in specified order in sql


kond.mohan
Posting Yak Master

213 Posts

Posted - 2015-04-02 : 03:55:57
yes got it..

SELECT name
FROM relationship
ORDER BY CASE WHEN name = 'self' THEN '1'
WHEN name = 'father' THEN '2'
ELSE name END ASC
Go to Top of Page

huangchen
Starting Member

37 Posts

Posted - 2015-04-02 : 05:50:03
unspammed
Go to Top of Page
   

- Advertisement -