SELECT
a.zddm AS zddm,
FROM_UNIXTIME(a.qrrq,'%y%m%d') AS qrrq,
b.spdm AS spdm,
CASE WHEN a.djlx = '0' THEN '配货' WHEN a.djlx = '1' THEN '横调' END djlx,
a.sl AS sl
FROM
ipos_zdjhd AS a LEFT JOIN ipos_zdjhdmx AS b
ON a.id = b.dj_id
WHERE
a.zddm = '8001' AND FROM_UNIXTIME(a.qrrq,'%y%m%d') BETWEEN '170101' AND '170131' AND a.djlx = '0'
GROUP BY
a.djbh;
分组后如何求出sl的总和,剔除重复的分组数据
sum(a.sl)就可以求和了
不要重复的分组数据,就在以上结果再group一次,having条件指定count(*) <= 1
试了好像不行