0
我想要得到的疾病總上週共從該表(tb_data):的Sql - 合併兩個查詢,使之行
P_ID Disease Date
1 A 2016-10-11
2 A 2016-10-11
3 A 2016-10-14
4 A 2016-10-19
,而我有這樣的查詢:
SELECT Disease AS DT,
COUNT(P_ID) AS PT
FROM tb_data
GROUP BY Disease
union
SELECT Disease AS DLW,
COUNT(P_ID) AS PLW
FROM tb_data
WHERE Date >= curdate() - INTERVAL DAYOFWEEK(curdate())+6 DAY
AND Date < curdate() - INTERVAL DAYOFWEEK(curdate())-1 DAY
GROUP BY Disease
ORDER BY 2 DESC, 1;
我想結果是什麼樣的這個
DT PT DLW PLW
A 4 A 3
不是這個
,因爲我想我的程序讀取這樣的:提前
哇,我今天新學的東西,謝謝! –