以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  排除已存在的数据  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=161706)

--  作者:lihe60
--  发布时间:2021/3/27 14:54:00
--  排除已存在的数据

select distinct a.存货名称报关外文 fro/m bg_报关明细 a left join bg_报关明细 b on a.存货名称报关外文=b.存货名称报关外文 where  b.存货名称报关外文 is not null and b.单据类型=\'报关价格\' and  a.单据类型=\'报关明细\'


截图为数据库,如何排除数据中单据类型为报关明细不包括在单据类型为报关价格的数据。


此主题相关图片如下:无标题.png
按此在新窗口浏览图片

[此贴子已经被作者于2021/3/27 14:55:43编辑过]

--  作者:lihe60
--  发布时间:2021/3/27 14:55:00
--  
上面的意思不知是否说的清楚。
--  作者:有点蓝
--  发布时间:2021/3/27 15:58:00
--  
不是很清楚。截图有报关明细和报关价格的数据看看,说明最终要什么数据
--  作者:lihe60
--  发布时间:2021/3/27 19:38:00
--  
如果"单据类型"为报关价格,且"存货名称报关外文"为1,则排除“单据类型”为报关明细,且"存货名称报关外文"为1的行。
--  作者:有点蓝
--  发布时间:2021/3/28 20:33:00
--  
试试
select distinct  存货名称报关外文 from bg_报关明细  where not exists(select * from  bg_报关明细 as b where b.存货名称报关外文=存货名称报关外文 and  b.单据类型=\'报关价格\')
--  作者:lihe60
--  发布时间:2021/3/29 14:53:00
--  

select distinct a.存货名称报关外文 fro/m bg_报关明细 a left join bg_报关明细 b on a.存货名称报关外文=b.存货名称报关外文 where  b.存货名称报关外文 is not null and b.单据类型=\'报关价格\' and  a.单据类型=\'报关明细\'

需要用上面的代码。

用in或exists,速度太慢。


--  作者:有点蓝
--  发布时间:2021/3/29 15:00:00
--  
请导出这个表部分数据测试