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.

 All Forums
 Other Forums
 Other Topics
 linking two queries

Author  Topic 

n0i0x
Starting Member

5 Posts

Posted - 2002-03-01 : 15:18:42
Hi I have the following code which lists the names of project contributors considered for a bonus and also the project leader also associated with the project. (empnin and pldrnin mean employee number and project leader number respectively)

SELECT e.lastname, e.firstname
FROM employee e, contributor c, project p
WHERE p.projno = c.projno
AND e.empnin = c.empnin
AND spent < (0.5 * budget)
AND exfinish < '30-JUN-02'
/
SELECT e.lastname, e.firstname
FROM employee e, project p
WHERE e.empnin = p.pldrnin
AND spent < (0.5 * budget)
AND exfinish < '30-JUN-02'
/

I was wondering if it is possible to link these two queries into 1?

Please advise

Thanks

Jay99

468 Posts

Posted - 2002-03-01 : 15:54:14
SELECT e.lastname, e.firstname, 'Mere-Mortal' as ContributorType
FROM employee e, contributor c, project p
WHERE p.projno = c.projno
AND e.empnin = c.empnin
AND spent < (0.5 * budget)
AND exfinish < '30-JUN-02'

UNION

SELECT e.lastname, e.firstname, 'Project Leader' as ContributorType
FROM employee e, project p
WHERE e.empnin = p.pldrnin
AND spent < (0.5 * budget)
AND exfinish < '30-JUN-02'

Jay
Go to Top of Page
   

- Advertisement -