shan_cool Posted March 6, 2006 Share Posted March 6, 2006 Hi All, I have a query and it displays set of records.. but i hav a pbm wit it. there will b one or more records for a particular employee.. but i need to display a single record for each of them which has the maxmimum m.startdate..... my query is select e.Emp_Id,e.Emp_FName,e.Emp_LName,e.Emp_Ug_Deg,e.PG_Deg,e.Emp_Desgn,e.Emp_DOJ,e.Base_Location,e.Emp_Ug_Year,e.PG_Year,i.Emp_Id,i.Test_Exp,i.Dev_Exp,i.Other_Exp,p.Prj_Code,p.Project_Name,p.Client,p.Location,m.Prj_Code,m.Emp_Id,m.Start_Date,m.End_Date,m.cty from HR_Emp_Det e,skill_master i,tdm_proposal p,tdm_prj_mem_det m where e.Emp_Id=i.Emp_Id and i.Emp_Id=m.Emp_Id and p.Prj_Code=m.Prj_Code and e.Emp_Status <> 'R' order by m.Emp_Id,m.Start_Date Ascno it shows as:for example.....101 |Sridevi |Senior Test Engineer |04-Apr-2003 |2.92 |2.66 |5.66| 1.25| 0.25| 7.16 |B.Sc.,MCA| 2001 |Available |India |Trade Finance - Polaris| Nil |Mumbai |01-Jun-2004 |31-Dec-2004 101 |Sridevi |Senior Test Engineer |04-Apr-2003 |2.92 |2.66 |5.66 |1.25| 0.25 |7.16| B.Sc.,MCA |2001 Available |India |Constact Contact Genesis |Nil |Bangalore |14-Feb-2005 |31-Aug-2005 BUt I nedd to display only101 |Sridevi |Senior Test Engineer |04-Apr-2003 |2.92 |2.66 |5.66 |1.25| 0.25 |7.16| B.Sc.,MCA |2001 Available |India |Constact Contact Genesis |Nil |Bangalore |14-Feb-2005 |31-Aug-2005 because 14-Feb-2005 is greater.. tell me how to change my queryRgds,Shan. Quote Link to comment https://forums.phpfreaks.com/topic/4191-query-display-pbm/ Share on other sites More sharing options...
wickning1 Posted March 6, 2006 Share Posted March 6, 2006 You need to join on a subquery that uses MAX(date) and GROUP BY. I will attempt to take a closer look tomorrow. Quote Link to comment https://forums.phpfreaks.com/topic/4191-query-display-pbm/#findComment-14570 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.