以下是我的查询。我在group by
声明中收到错误,我无法弄清楚原因。我也包含了错误。
SELECT a.[Order Date]
,a.[Customer #]
,a.[Order #]
,a.[Order Type]
,OrderTotal
,CASE
WHEN c.OfferType IN ('Catalog')
THEN 'Y'
ELSE 'N'
END AS 'Catalog Match'
,b.ChannelGroup
FROM LWPIM.dbo.MarketingReporting a
LEFT JOIN (
SELECT sum([Total Price]) AS OrderTotal
FROM LWPIM.dbo.MarketingReporting
WHERE [Order Date] BETWEEN '2016-01-01'
AND '2016-06-30'
GROUP BY [Order Date]
,[Total Price]
) d
LEFT JOIN User_Sandbox.dbo.OfferCodeOfferType c ON a.[Offer Number] = c.OfferCode
AND a.[Matchback Offer Number] = c.OfferCode
LEFT JOIN User_Sandbox.dbo.GAData2016 b ON a.[Order #] = b.Order_Number
GROUP BY a.[Customer #]
,a.[Order #]
,a.[Order Date]
,a.[Order Type]
,OrderTotal
,CASE
WHEN c.OfferType IN ('Catalog')
THEN 'Y'
ELSE 'N'
END
,b.ChannelGroup
ORDER BY a.[Order Date] DESC
,OrderTotal DESC
第15行,第15行,第1行,第16行 关键字' group'附近的语法不正确。