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.
| Author |
Topic |
|
JeffS23
Posting Yak Master
212 Posts |
Posted - 2010-02-01 : 21:05:58
|
| I am getting the following error and unsure how to resolve it:Msg 116, Level 16, State 1, Line 1Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.My Query:SELECT * from PatientVisitWHERE PatientVisitId NOT IN(SELECT * from PatientVisitResource pvrJOIN PatientVisit pv on pvr.PatientVisitID = pv.PatientVisitId)I am essentially trying to write a query that gives me a list of all visits without a Resource. Any insight is appreciated. |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2010-02-01 : 21:14:29
|
SELECT PV.* from PatientVisit PVLeft Outer join PatientVisitResource PVRon PVR.PatientVisitID = PV.PatientVisitIdWhere PVR.PatientVisitID is null |
 |
|
|
JeffS23
Posting Yak Master
212 Posts |
Posted - 2010-02-01 : 21:36:04
|
| sodeep - Thank you very much!! |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2010-02-01 : 23:20:46
|
| Make sure you know the evils of using NOT IN with Null values before using khtan's solution. Not Exists will be much safer.Harsh Athalyehttp://www.letsgeek.net/ |
 |
|
|
|
|
|