Using result from sub query in the main query
I have a table with employees first name and last name and a status
variable. What I want is to check employees with status = 1 to check
against employees with status = 0 and having same first and last name.
What I did is
select fname,lname
from t
where status=1
and (fname,lname) IN
(select t1.fname,t1.lname
from t1,t2
where t1.fname=t2.fname
and t1.lname=t2.lname
and t1.status=0)
I want to use t1.fname and t1.lname in above query so I can show some
results like that
// 4columns
2 for status=1 and 2 for status=0
Emp with status=1 : Emp with status=0
EmpAFname:EmpALname :EmpAFname:EmpALname
EmpBFname:EmpBLname :EmpBFname:EmpBLname
Here is sample Data
No comments:
Post a Comment