我有两张表,例如 ONE 和 TWO,我的表更大且结构不同,但有些字段重合。
我怎样才能得到表QUERY?
我可以只用一个带有 GROUP 和 SUM 的表来完成,但是如何在 QUERY 中添加最后一列?可能吗?
SELECT Date, SUM(Apples), SUM(Oranges) FROM One
GROUP BY Date
我有两张表,例如 ONE 和 TWO,我的表更大且结构不同,但有些字段重合。
我怎样才能得到表QUERY?
我可以只用一个带有 GROUP 和 SUM 的表来完成,但是如何在 QUERY 中添加最后一列?可能吗?
SELECT Date, SUM(Apples), SUM(Oranges) FROM One
GROUP BY Date
SELECT one.Date, one.place, SUM(Apples), SUM(Oranges), SUM(Grapes)
FROM One left join Two on one.place = two.place and one.date = two.date
GROUP BY one.date, one.place
将返回第一个表中的所有位置和正确的计数
SELECT Date, one.place, SUM(Apples), SUM(Oranges), SUM(Grapes)
FROM One left join Two on one.place = two.place and one.[Date] = two.[Date]
GROUP BY Date