聯合收割機2計數SQL組我有2個表具有相同的結構,每個地方我使用幾乎相同的SQL來選擇和SUM。MYSQL:通過一年
SQL1:
SELECT YEAR, SUM(GENERATION) AS generationA, SUM(TRANSMISSION) AS transmissionA
FROM tableA
WHERE YEAR BETWEEN '2013' AND '2016'
AND POWER_PLANT_ID = 'ABC1'
AND STATUS = 'V'
AND transmission IS NOT NULL
GROUP BY YEAR
SQL2:
SELECT YEAR, SUM(GENERATION) AS generationB, SUM(TRANSMISSION) AS transmissionB
FROM tableB
WHERE YEAR BETWEEN '2013' AND '2016'
AND POWER_PLANT_ID = 'ABC1'
AND STATUS = 'V'
AND transmission IS NOT NULL
GROUP BY YEAR
如何通過其年這2 SQL來組結合?
什麼是你期望的輸出?請提供一些樣本輸入和期望的輸出 – 1000111