Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
sureshsmanian
Starting Member
31 Posts |
Posted - 2011-09-21 : 04:22:28
|
| HiI have two tablesApplicant (ApplicantId, Name)Applicant---------AP1 Suniyas AP2 ArunAP3 SurekaQualificationDetail(Qid,Qualification,OrderNo,ApplicantId)Qualification-------------Q01 Bcom 1 AP1Q02 MCom 2 AP1Q03 CIMA 3 AP1Q04 BS 1 AP2Q05 MS 2 AP2Q06 BTech 1 AP3Q07 MTech 2 AP3Q08 PhD 3 AP3 I would like to display the details of each applicant only with highest qualification(based on orderno column)Required output---------------Sno AppName HighestQualification--------------------------------1 Suniyas CIMA2 Arun MS3 Sureka PhD------------------------Thanks for your help.RgdsSSM |
|
|
Ranjit.ileni
Posting Yak Master
183 Posts |
Posted - 2011-09-21 : 04:37:11
|
| [code]select q.ApplicantId,a.Name,q.Qualificationfrom QualificationDetail qinner join (select ApplicantId,MAX(OrderNo) MaxQualif from QualificationDetail group by ApplicantId)Der on Der.ApplicantId=q.ApplicantId and Der.MaxQualif=q.OrderNoinner join Applicant a on a.ApplicantId=q.ApplicantId [/code]--Ranjit |
 |
|
|
sureshsmanian
Starting Member
31 Posts |
Posted - 2011-09-21 : 05:09:42
|
| @RanjitThanks for ur help. Its working fine.RgdsSSM |
 |
|
|
Ranjit.ileni
Posting Yak Master
183 Posts |
Posted - 2011-09-21 : 05:40:23
|
| Welcome suresh!--Ranjit |
 |
|
|
|
|
|