27,579
社区成员
发帖
与我相关
我的任务
分享
问题描述:
以下查出的结果没想明白,共5句查询,都有去除重复值
1、查询订单中日期大于今年的供应商笔数且金额小于等于10W数据,结果为648笔
2、查询订单中日期大于今年的供应商笔数且金额大于10W数据且小于50W数据,结果为227笔
3、查询订单中日期大于今年的供应商笔数且金额大于50W数据且等于100W数据,结果为40笔
4、查询订单中日期大于今年的供应商笔数且金额大于100W数据,结果为30笔
5、查询订单中日期大于今年的供应商笔数,结果为727
疑问:
因为1-4查询条件都不重复,他们之间没有交叉的数据
表面上看数据我认为应该为: 648+227+40+30
但是第5条查总数为727 是什么原因,没想明白
select count( distinct BizPartnerId) as 小于等于10万
from purBillOrderMaster where PermitState=2 and BillDate>=20170101 and X_ActOrdOAmount<=100000
//*结果值: 648*//
select count( distinct BizPartnerId) as 大于10万小于等于50万
from purBillOrderMaster where PermitState=2 and BillDate>=20170101 and X_ActOrdOAmount >100000
and X_ActOrdOAmount <=500000
//*结果值:227*//
select count( distinct BizPartnerId) as 大于50万小于等于100万
from purBillOrderMaster where PermitState=2 and BillDate>=20170101 and X_ActOrdOAmount >500000
and X_ActOrdOAmount <=1000000
//*结果值:40*//
select count( distinct BizPartnerId) as 大于100万
from purBillOrderMaster where PermitState=2 and BillDate>=20170101 and X_ActOrdOAmount >1000000
//*结果值:30*//
select count( distinct BizPartnerId) as 总数量
from purBillOrderMaster where PermitState=2 and BillDate>=20170101
//*结果值: 727*//