Hi...
I have a table with the below records and I need to group by the name
and order by the Code
Code Name
----- ----------
P 1 dddd
F 1 ffff
A 1 wwww
I 2 AAA
R 1 ffff
Z 2 AAA
Result should be such that Code with A should be sorted in the Group
with 1 and so on
Name Code
----------- -----
1 wwww A
1 ffff F
1 dddd P
1 ffff R
2 AAA I
2 AAA Z
I have written this query but it gives me the below output :
SELECT Name,Code FROM (SELECT ROW_NUMBER() OVER(PARTITION BY
Name,Code) AS rn, Name,Code FROM tablename ) AS T WHERE rn = 1 order BY
Name
Name Code
----------- -----
1 dddd P
1 ffff F
1 ffff R
1 wwww A
2 AAA I
2 AAA Z
I have tried all combintaions but still am not able to group by the
Code
Thanks.....
RaiNDeEr