SELECT month(date), SUM(amount) as amount
FROM expendituretotal
GROUP BY month(date);
我想要这样的输出:
month amount1 amount2
---------------------------
June 2000 3000
答案 0 :(得分:0)
正确答案。
SELECT e.month
,e.expp AS amount
,e1.depp AS amount
FROM (
SELECT month(DATE) AS month
,SUM(amount) AS expp
FROM expendituretotal
GROUP BY month(DATE)
) e
,(
SELECT month(DATE) AS month
,SUM(amount) AS depp
FROM totalamount
GROUP BY month(DATE)
) e1
WHERE e.month = e1.month