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 |
raguyazhin
Posting Yak Master
105 Posts |
Posted - 2013-12-28 : 02:41:45
|
Hi,Result Not Shown in NOT IN Used Query.The First Query Return 1 Row for the criteriaselect * from RE_SURGERY_SCHEDULE where RSS_SURGERY_SCHEDULE_NUM='SG10131212/0003'The Second Query Return 0 Row for the criteriaselect * from WA_ADMISSION_TXN where WAT_SURGERY_SCHEDULE_NUM='SG10131212/0003'Here I combine two queries but result not shown what is mistake in this queryselect * from RE_SURGERY_SCHEDULEwhere RSS_SURGERY_SCHEDULE_NUM not in (select WAT_SURGERY_SCHEDULE_NUM from WA_ADMISSION_TXN) --Ragu |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-28 : 03:18:26
|
you should be using NOT EXISTS I guessselect * from RE_SURGERY_SCHEDULE rwhere NOT EXISTS(select 1 from WA_ADMISSION_TXN WHERE r.RSS_SURGERY_SCHEDULE_NUM = WAT_SURGERY_SCHEDULE_NUM ) ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
Kristen
Test
22859 Posts |
Posted - 2013-12-28 : 09:31:26
|
[code]select * from RE_SURGERY_SCHEDULEwhere RSS_SURGERY_SCHEDULE_NUM not in (select WAT_SURGERY_SCHEDULE_NUM from WA_ADMISSION_TXN) [/code]will fail if the inner SELECT returns a NULL.Does this return any rows?[code]select TOP 100 *from WA_ADMISSION_TXNWHERE WAT_SURGERY_SCHEDULE_NUM IS NULL[/code] |
|
|
|
|
|