There is 2 tables 1st table student_reg (col- id, stu_name) ,2nd table student_details (col-date_of_birth and interview_date,stu_id)student_reg data.1 Anna2 smita3 smita 4 madhuri5 madhuri6 madhuri7 devistudent_details data.date of birth interview_date student_id 1-3-2012 1-3-2012 11-1-2012 21-3-2012 21-2-2012 21-3-2012 331-1-2011 1-6-2012 431-1-2011 11-7-2012 531-1-2011 21-3-2012 631-1-2015 1-3-2012 7my question is student-id 4,5,7 is same name and same dob birth so last_applied_date will be of previous id interview_dateneed output is : student_id student_name dob_of_birth last_applied_date4 Madhuri 31-1-2011 Null5 Madhuri 31-1-2011 1-6-20126 Madhuri 31-1-2011 11-7-2012 .my query isselect t.*,CASE WHEN count(t.candidate_name)>1 and count(t.date_of_birth)>1 THEN min(c.interview_date)end as last_appiled_date,CASE WHEN cand_status= 0 THEN concat('Rejected in', " " , t.round)WHEN cand_status= 1 THEN concat('Selected in', " " , t.round)WHEN cand_status=2 THEN concat('On hold in', " " , t.round) end as Interview_statusfrom candidate_registration intr inner join candidate_personal_detail c on intr.id=c.candidate_id left JOIN (select c.candidate_id,candidate_name,date_of_birth,c.interview_date,round,(select can_status from candidate_status where id=max(b.id)) as cand_statusfrom candidate_status b right join candidate_registration a on a.id=b.candidate_id inner join candidate_personal_detail c on a.id=c.candidate_id left join interview_round i on i.id=b.round_id group by a.id,candidate_name, date_of_birth) ton c.candidate_id = t.candidate_idand c.interview_date = t.interview_dategroup by intr.id,candidate_name, date_of_birth;
↧