Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
Hi Friends,

I have a Currency table with records as follows :

ID Name
1 INR
2 USD
3 SGD
4 EURO
. .
. .

When I fire a query like, select * from Currecny, I get the recordset as shown.

But I want to get " SGD " as my first record, then all remaining records.

How can I get this?

Any help appreciated.

Thanks,
Lok.
Posted
Updated 22-Dec-11 19:47pm
v2

Amir's answer is enough but here alternative solution
Add an another column in your table(Ex. Default or DisplayOrder), see below table.
ID Name IsDefault
-----------------
1 INR   N
2 USD   N
3 SGD   Y
4 EURO  N

Use the Below Query
SQL
SELECT * FROM [Table] ORDER BY SGD DESC

ID Name DisplayOrder
-----------------
1 INR   2
2 USD   3
3 SGD   1
4 EURO  4

SQL
SELECT * FROM [Table] ORDER BY DisplayOrder
 
Share this answer
 
Comments
Amir Mahfoozi 23-Dec-11 1:05am    
+5 Yes, I always use display order in my own projects :)
Rakshith Kumar 15-Oct-13 5:22am    
nice one :)
RaviRanjanKr 23-Dec-11 1:36am    
5+
SQL
select * from currency
order by
case name
when 'SGD' then 1
else 2
end
 
Share this answer
 
Comments
Amir Mahfoozi 23-Dec-11 4:36am    
+5 Another good solution.
Scubapro 23-Dec-11 4:38am    
Tnx!
Try this :
SQL
select * from currency where id=3
union all 
select * from color where id<>3
 
Share this answer
 
Comments
thatraja 23-Dec-11 1:02am    
5!
RaviRanjanKr 23-Dec-11 1:36am    
My 5+
Lokesh Zende 23-Dec-11 3:11am    
Thanks Amir... :)
Amir Mahfoozi 23-Dec-11 4:27am    
You're welcome :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900