This is a discussion on sorting table within the SQL Server forums, part of the Microsoft SQL Server category; --> Hi friends, please help me in sorting this table. the table should be sorted based on LASTNAME, and then ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi friends, please help me in sorting this table. the table should be sorted based on LASTNAME, and then the ID (only non-zero id should be sorted). ID LASTNAME --------+---------------------------- 2 FFF 1 XXX 0 CCC 1 DDD 2 BBB 0 EEE 0 GGG 3 III 3 HHH 4 ZZZ 4 ZZZ The expected table is as follows ID LASTNAME --------+---------------------------- 2 BBB 2 FFF 0 CCC 1 DDD 1 XXX 0 EEE 0 GGG 3 HHH 3 III 4 XYZ 4 ZZZ should be sorted based on last name and should be grouped with the same ID, except for the ID as 0 Thanks in Advance.. Arun |