Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

issue with unique selection

Status
Not open for further replies.

SqlHunter

Programmer
Jun 3, 2004
166
US
Here I have a set of data and I need to export these dataset from excel to sql server table.Here When I need to select only unique emp_id with maximum exam_id but even when I use the distinct its populating the second one



-------------------------------------------------------------------------------- Emp_id exam_id Grade_obtained
0001002492 1903956 Grade B
0001002492 1903956
0001002492 1903956 Grade A
0001049121 1963794 Grade B
1963344 Grade C
1963444 Grade D
 
Code:
SELECT Emp_Id, max(exam_id),Grade_Obtained
FROM YourTable
Group By Emp_Id

[bandito] [blue]DBomrrsm[/blue] [bandito]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top