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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to do this JOIN?

Author  Topic 

dlorenc
Posting Yak Master

172 Posts

Posted - 2008-10-07 : 12:52:43
The left table contains a list of projects. Each project has a project_ID.

The right table contains a list of status reports, several for each project (or none if the project has not filed a status report), each status report carries the project_ID.

I would like to produce a report containing the list of project that have NOT filed a status report...

So I am trying to produce a (distinct?) list fromt he project table, where project_ID does not exist in the status report table...

*scratching my head on this one*

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-07 : 12:57:41
SELECT p.*
FROM projects p
LEFT JOIN StatusReport sr
ON sr.Project_ID=p.Project_ID
WHERE sr.Project_ID IS NULL
Go to Top of Page

dlorenc
Posting Yak Master

172 Posts

Posted - 2008-10-07 : 13:11:58


that was just what I wanted...simple, yet elegant...thank you!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-07 : 13:22:28
welcome
Go to Top of Page
   

- Advertisement -