码迷,mamicode.com
首页 > 其他好文 > 详细

折线图返回值---每一天的值

时间:2018-11-09 10:47:37      阅读:145      评论:0      收藏:0      [点我收藏+]

标签:cal   and   等于   calendar   tmp   nbsp   --   left join   sum   

SELECT
A.datelist AS pick_dt,
IFNULL(B.pick_cnt, 0) pick_cnt,
IFNULL(B.cust_cd, 0) cust_cd             //IFNULL(A,B) --如果结果不等于null,则返回A,等于null,就返回B
FROM
calendar A
LEFT JOIN (
SELECT
sum(pick_cnt) AS pick_cnt,
pick_dt,
cust_cd
FROM
`crmkh_gp_bas_s_cust_pick_tmp`
WHERE
cust_cd = 1107607777
GROUP BY
pick_dt
HAVING
pick_dt BETWEEN ‘2018-11-02‘
AND ‘2018-11-08‘
) B ON A.datelist = B.pick_dt
WHERE
A.datelist BETWEEN ‘2018-11-02‘
AND ‘2018-11-08‘

折线图返回值---每一天的值

标签:cal   and   等于   calendar   tmp   nbsp   --   left join   sum   

原文地址:https://www.cnblogs.com/Darkqueen/p/9933418.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!