Problem with T SQL
 

select ItemGroupDefinitionID,Description from
(
Select 'ALL' as ItemGroupDefinitionID,'DISPLAY ALL PRODUCTS' as Description

union

SELECT cast(A.ItemGroupDefinitionID as varchar),Description FROM [ItemGroupDefinition] A

)B

ORDER BY  CASE WHEN ItemGroupDefinitionID='ALL' THEN 0 ELSE ItemGroupDefinitionID END

I want the result set to be sorted according to the Description  rather than Ids. The condition is such that the first row remains unchanged because I need to display all the products , the sort has to be done from the second row based on the description. 

 result set:

ItemGroupDefinitionID Description
ALL    DISPLAY ALL PRODUCTS
2       Network Integration
3       Network Drops
5      CH Square Feet
6      FH Square Feet
8      EA CH Square Feet
9      EA CH LBand Square Feet

October 31st, 2013 6:25am

select ItemGroupDefinitionID,Description from
(
Select 'ALL' as ItemGroupDefinitionID,'DISPLAY ALL PRODUCTS' as Description,0 as SortId

union

SELECT cast(A.ItemGroupDefinitionID as varchar),Description FROM [ItemGroupDefinition] A, as SortId

)B

ORDER BY SortId ASC,Description ASC

Free Windows Admin Tool Kit Click here and download it now
October 31st, 2013 6:37am

Hey Sandeep,

Many Thanks !

It worked

Ajit

October 31st, 2013 6:48am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics