此主题相关图片如下:1.png
此主题相关图片如下:2.png
此主题相关图片如下:3.png
同一个数据库,统计出来结果不对,实际销售数字是6件,却显示销售16件,配货数量也不一样,配货数实际就是23件
[此贴子已经被作者于2024/5/11 2:07:28编辑过]
SE LECT {SDPHDMX}.DJBH AS 批次号, {GONGHUOSHANG}.GHSMC AS 供货商, SUM({SDPHDMX}.SL) AS 配货数, SUM(fQuantity) AS 销售数 FROM ((({SDPHD} INNER JOIN {SDPHDMX} ON {SDPHD}.DJBH = {SDPHDMX}.DJBH) INNER JOIN {shangpin_A} ON {SDPHDMX}.SPDM = {shangpin_A}.SPDM) INNER JOIN {GONGHUOSHANG} ON {SHANGPIN_A}.GHSDM = {GONGHUOSHANG}.GHSDM) INNER JOIN {SG_Gatherings} ON {SDPHDMX}.spdm = {SG_Gatherings}.vstyle GROUP BY {SDPHDMX}.DJBH,{GONGHUOSHANG}.GHSMC ORDER BY 批次号 DESC
这是第二张图片的代码
[此贴子已经被作者于2024/5/11 2:06:55编辑过]
举一个具体的批号说明一下,比如上面说的【
实际销售数字是6件】,这个6是怎么查的?
还有各个表的关系麻烦说明一下
[此贴子已经被作者于2024/5/11 14:19:12编辑过]
试试
select c.批次号,c.供货商,c.配货数,d.销售数 from (SELECT {SDPHDMX}.DJBH AS 批次号, {GONGHUOSHANG}.GHSDM ,{GONGHUOSHANG}.GHSMC AS 供货商, SUM({SDPHDMX}.SL) AS 配货数 FROM ((({SDPHD} INNER JOIN {SDPHDMX} ON {SDPHD}.DJBH = {SDPHDMX}.DJBH) INNER JOIN {shangpin_A} ON {SDPHDMX}.SPDM = {shangpin_A}.SPDM) INNER JOIN {GONGHUOSHANG} ON {SHANGPIN_A}.GHSDM = {GONGHUOSHANG}.GHSDM) GROUP BY {SDPHDMX}.DJBH,{GONGHUOSHANG}.GHSDM ,{GONGHUOSHANG}.GHSMC ) as c inner join (select a.GHSDM, SUM(fQuantity) AS 销售数 from {shangpin_A} as a inner join {SG_Gatherings} as b on a.SPDM = b.vstyle group by a.GHSDM) as d on c.GHSDM = d.GHSDM ORDER BY c.批次号 DESC
蓝老师,我用的是sql,这个abc该如何修改,看了半天没有明白