PDA

View Full Version : Sub Query Validations


shan_cool
12-27-2005, 06:45 AM
hi all


my sub query is:
select Max(m.Start_Date)
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' and m.Emp_Id='20' group by m.Emp_Id

This give me correct output.. this output is passed to the where condition of main query.

my main 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,Max(m.Start_Date) ,
IF(m.End_Date="",m.End_Date,
Max(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' and m.Emp_Id='20' and m.Start_Date='2003-02-01' group by m.Emp_Id

here i hav hard coded the date in where condition... it works fine.. but i need to merge both queries as:


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,Max(m.Start_Date) ,
IF(m.End_Date="",m.End_Date,
Max(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' and m.Emp_Id='20' and m.Start_Date="select Max(m.Start_Date)
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' and m.Emp_Id='20' group by m.Emp_Id "
group by m.Emp_Id

this doesn't work
gimme some idea how to implement this..

rgds,
shan
India...