﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / SQL Server 2008 - General  / Sorting - Custom Based. / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Thu, 23 May 2013 01:34:13 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Sorting - Custom Based.</title><link>http://www.sqlservercentral.com/Forums/Topic1394554-391-1.aspx</link><description>If those 2 columns are in a table, then[code="sql"]SELECT name FROM SomeTable ORDER BY sortorder[/code]No CTE required</description><pubDate>Mon, 10 Dec 2012 05:44:45 GMT</pubDate><dc:creator>GilaMonster</dc:creator></item><item><title>RE: Sorting - Custom Based.</title><link>http://www.sqlservercentral.com/Forums/Topic1394554-391-1.aspx</link><description>wrap in a cte then just select the one column</description><pubDate>Mon, 10 Dec 2012 05:39:45 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: Sorting - Custom Based.</title><link>http://www.sqlservercentral.com/Forums/Topic1394554-391-1.aspx</link><description>Hi anthonyIs it Possible to get only single column name.name	sortorderSmith	1Jack	2David	3Ellen	4john	5Peter	6sortorder column is not required</description><pubDate>Mon, 10 Dec 2012 05:35:18 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Sorting - Custom Based.</title><link>http://www.sqlservercentral.com/Forums/Topic1394554-391-1.aspx</link><description>Thaaaanks anthonyGreat.....!</description><pubDate>Mon, 10 Dec 2012 05:30:56 GMT</pubDate><dc:creator>Minnu</dc:creator></item><item><title>RE: Sorting - Custom Based.</title><link>http://www.sqlservercentral.com/Forums/Topic1394554-391-1.aspx</link><description>If you have some way of telling SQL the sort order then yes[code="sql"]declare @table table (name varchar(10))insert into @table values ('Smith'),('Jack'),('David'),('Ellen'),('john'),('Peter')select * from @table order by name ascselect * from @table order by name descselect *, case name when 'Smith' then 1 when 'jack' then 2 when 'david' then 3 when 'ellen' then 4 when 'john' then 5 when 'peter' then 6 end as sortorder from @table order by sortorder[/code]</description><pubDate>Mon, 10 Dec 2012 05:09:52 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>Sorting - Custom Based.</title><link>http://www.sqlservercentral.com/Forums/Topic1394554-391-1.aspx</link><description>Hi Team,Is it possible to sort records in custom.Eg:i've below records in a table.johnPetersmithEllenJackDavidi want in below order Smith Jack David Ellen john Peter</description><pubDate>Mon, 10 Dec 2012 05:04:30 GMT</pubDate><dc:creator>Minnu</dc:creator></item></channel></rss>