如果子查询的值在“NOT IN”中返回空白该怎么办 [英] what to do if value of subquery returns blank in "NOT IN "
本文介绍了如果子查询的值在“NOT IN”中返回空白该怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是我的查询
从Challan_tb中选择distinct(Challan_No),其中Challan_No不存在(从Invoice_tb中选择Challan_No,其中Customer_ID = 2和InvYear = 2013)和InvYear = 2013和Customer_ID = 2
子查询返回空白,因此外部查询不起作用
请帮助
below is my query
select distinct(Challan_No) from Challan_tb where Challan_No not exist (select Challan_No from Invoice_tb where Customer_ID =2 and InvYear=2013) and InvYear=2013 and Customer_ID =2
the sub query is returning blank so outer query not working
please Help
推荐答案
尝试以下查询。希望这就是你所需要的。
从Challan_tb中选择distinct(Challan_No),其中Challan_No不在(从Invoice_tb中选择isnull(Challan_No,0),其中Customer_ID = 2且InvYear = 2013)和InvYear = 2013和Customer_ID = 2
Try the following query. Hope this what you need.
select distinct(Challan_No) from Challan_tb where Challan_No not in (select isnull(Challan_No,0) from Invoice_tb where Customer_ID =2 and InvYear=2013) and InvYear=2013 and Customer_ID =2
这篇关于如果子查询的值在“NOT IN”中返回空白该怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文