Hi,

I want to sort the set of records within each group.

For ex : I'm sorting the records in ascending order by deptid & sorting the records within the group in decending order by empid (row 2 & 3). Also I want to select the first record of each group.

DeptID, Name, EmpID
1000, AAA, 100
3000, BBB, 200
500, CCC, 300
1000, DDD, 50

Expected output1 :

DeptID, Name, EmpID
500, CCC, 300
1000, AAA, 100
1000, DDD, 50
3000, BBB, 200

Expected output2 :

DeptID, Name, EmpID
500, CCC, 300
1000, AAA, 100
3000, BBB, 200

Thanks,
Arunn