-2
我已經找到了適合我的解決方案的完美代碼,但是很遺憾,我還沒有找到一種方法來爲那一天添加一個小的添加項,即SUM
selling_price
。SUM本週銷售價格
SQL代碼:
SELECT
COUNT(WEEKDAY(`date`) = 0 OR NULL) AS Mon,
COUNT(WEEKDAY(`date`) = 1 OR NULL) AS Tue,
COUNT(WEEKDAY(`date`) = 2 OR NULL) AS Wed,
COUNT(WEEKDAY(`date`) = 3 OR NULL) AS Thu,
COUNT(WEEKDAY(`date`) = 4 OR NULL) AS Fri,
COUNT(WEEKDAY(`date`) = 5 OR NULL) AS Sat,
COUNT(WEEKDAY(`date`) = 6 OR NULL) AS Sun
FROM orders
WHERE `date` >= CURRENT_DATE() - INTERVAL (WEEKDAY(CURRENT_DATE())) DAY
AND `date` < CURRENT_DATE() + INTERVAL 1 DAY
更新正確的數據樣本和預期的結果你的問題.. – scaisEdge