首页 新闻 会员 周边 捐助

MySQL数据库

0
[已关闭问题] 关闭于 2017-10-12 19:17

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的总和,剔除重复的分组数据

孤鹰2020的主页 孤鹰2020 | 初学一级 | 园豆:167
提问于:2017-10-12 09:40
< >
分享
所有回答(1)
0

sum(a.sl)就可以求和了

不要重复的分组数据,就在以上结果再group一次,having条件指定count(*) <= 1

陈子 | 园豆:241 (菜鸟二级) | 2017-10-12 09:47

试了好像不行

支持(0) 反对(0) 孤鹰2020 | 园豆:167 (初学一级) | 2017-10-12 10:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册