我苦苦尋找的遠離這2個查詢組合...香港專業教育學院試圖subquerys,連接,聯合和有沒有運氣:(結合的MySQL查詢
查詢
SELECT DATE(crtdtime) AS cntldate, sd_class, COUNT(crtdtime) AS created
FROM master
WHERE DATE(crtdtime) = '2011-11-16'
GROUP BY cntldate, sd_class
將會產生
+------------+----------+---------+
| cntldate | sd_class | created |
+------------+----------+---------+
| 2011-11-16 | CUST | 2226 |
| 2011-11-16 | NET | 238 |
+------------+----------+---------+
查詢乙
SELECT DATE(rstdtime) AS cntldate, sd_class, COUNT(rstdtime) AS restored
FROM master
WHERE DATE(rstdtime) = '2011-11-16'
GROUP BY cntldate, sd_class
將會產生
+------------+----------+----------+
| cntldate | sd_class | restored |
+------------+----------+----------+
| 2011-11-16 | CUST | 2315 |
| 2011-11-16 | NET | 221 |
+------------+----------+----------+
但想最終的結果是...
+------------+----------+---------+----------+
| cntldate | sd_class | created | restored |
+------------+----------+---------+----------+
| 2011-11-16 | CUST | 2226 | 2315 |
| 2011-11-16 | NET | 238 | 221 |
+------------+----------+---------+----------+
將不勝感激任何幫助。
謝謝。
謝謝大家對你的幫助是非常非常感謝,並與** Yahia的**版本,因爲它給了我最大的靈活性。 – mybigman
@mybigman歡迎您:-)請不要忘記將upvote/mark標記爲已接受任何有幫助的答案(請參閱http://meta.stackexchange.com/questions/5234/how-does-accepting-an-回答工作)。 – Yahia