我整理桌子有点麻烦。我有一个从查询生成表的代码。但我错了日期所以我明白了
例子:
2016-9 84182320 2
2016-9 MVH82465446 11164
2016-9
2017-4 MVH84734664 18
2015-10 84078897 242
2015-10 84079056 16
2015-10 84184764 9
2015-11 82072021 70
2015-11 82277363 6
2015-12 84079056 25
2015-12 84079070 24
2016-10 82379452 50
2016-11 150202 196
这是一个查询:
SELECT
CONCAT(YEAR(Orderdatum),'-',MONTH(Orderdatum) ++ 0) ASOrderdatum,
Artikelnr,
OrderKund,
SUM(Forspris) as Forspris,
SUM(Levereratantal) as Levereratantal
FROM orderhuvud
LEFT JOIN orderrad ON orderhuvud.Ordernummer = orderrad.Ordernummer
WHERE OrderKund = '15'
AND Orderdatum between '2015-04-16' AND '2017-04-04'
GROUP BY CONCAT(YEAR(Orderdatum),MONTH(Orderdatum)) + 0, Artikelnr
最佳答案
你没有点菜
SELECT CONCAT(YEAR(Orderdatum),'-',MONTH(Orderdatum) ++ 0) AS Orderdatum
,Artikelnr
,OrderKund
, SUM(Forspris) as Forspris
,SUM(Levereratantal) as Levereratantal
FROM orderhuvud
left JOIN orderrad on orderhuvud.Ordernummer = orderrad.Ordernummer
where OrderKund = '15'
AND Orderdatum between '2015-04-16'
AND '2017-04-04'
GROUP BY CONCAT(YEAR(Orderdatum),MONTH(Orderdatum)) + 0,Artikelnr
ORDER BY YEAR(Orderdatum), MONTH(Orderdatum), Artikelnr