October 12, 2011 at 12:33 am
I have a list of records in a table of Locations,
Africa, ASIA, Europa, America and would like to select and order by locations,
i would like to always start with ASIA since its the home location and the rest "order by Asc". how do i go about this.
Regards
October 12, 2011 at 2:46 am
Use a CASE expression in the ORDER BY clause.
DECLARE @Locations TABLE (
LocationName varchar(10)
)
INSERT INTO @Locations VALUES('Africa')
INSERT INTO @Locations VALUES('ASIA')
INSERT INTO @Locations VALUES('America')
INSERT INTO @Locations VALUES('Europa')
SELECT *
FROM @Locations
ORDER BY CASE LocationName WHEN 'ASIA' THEN 0 ELSE 1 END, LocationName
Hope this helps
Gianluca
-- Gianluca Sartori
October 12, 2011 at 3:04 am
Thnaks so much. It works .
Regards
October 12, 2011 at 3:19 am
You're welcome.
Glad I could help
-- Gianluca Sartori
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply