1. 程式人生 > >折線圖返回值---每一天的值

折線圖返回值---每一天的值

null pan col 線圖 ifnull spa 折線 tel between

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‘

折線圖返回值---每一天的值