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 |
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2008-09-26 : 08:56:13
|
| I want to compare the PAN field from the current week file (NewDiary) to last week file to determined if the case is cleared.Is this correct? Confused which table is listed first as I get different results from them both.SELECT *FROM NewDiaryWHERE PAN NOT IN (SELECT PANFROM LastweekdiaryWHERE PAN = PAN)ORDER BY LName |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-26 : 09:04:30
|
[code]SELECT nd.*FROM NewDiary AS ndLEFT JOIN LastWeekDiary AS lwd ON lwd.Pan = nd.PanWHERE lwd.Pan IS NULLORDER BY nd.LName[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-26 : 09:05:02
|
[code]SELECT nd.*FROM NewDiary AS ndWHERE NOT EXISTS (SELECT * FROM LastWeekDiary AS lwd WHERE lwd.Pan = nd.Pan)ORDER BY nd.LName[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
JJ297
Aged Yak Warrior
940 Posts |
Posted - 2008-09-26 : 09:11:41
|
| Thanks! |
 |
|
|
|
|
|