December 23, 2009 at 7:50 am
Hi,
I have the inputs in the following order.
CREATE TABLE #ABC
(
clientname VARCHAR(30)
)
INSERT INTO #ABC
SELECT 'UTA01' UNION ALL
SELECT 'UTA02' UNION ALL
SELECT 'TTA01' UNION ALL
SELECT 'TTA02' UNION ALL
SELECT 'DTA01' UNION ALL
SELECT 'DTA02'
And the Desired Output is
UTA01
TTA01
DTA01
UTA02
TTA02
DTA02
in only one query
December 23, 2009 at 7:56 am
SELECT clientname
FROM #ABC
ORDER BY SUBSTRING(clientname,3,3)
,SUBSTRING(clientname,1,2)DESC
-Vikas Bindra
December 23, 2009 at 7:57 am
what are you rules for ordering?
You really need a primary key / clustered index to define the order
December 23, 2009 at 8:02 am
You can refer to BOL / MSDN for rules/ in how you can use the order by clause.
Abhijit - http://abhijitmore.wordpress.com
December 23, 2009 at 11:32 pm
Thanks vikas.
Its working fine..
December 23, 2009 at 11:32 pm
Thanks Abhijit,.. I will check the rules once.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply