0
我想選擇dc.description不同的c。[weight]之和。我正在尋找5個案例,例如:dc.description如'failed%'然後計算c。[寄存參考]的總和。使用大小寫以檢索使用通配符的聚合
我會怎麼做呢?
SELECT lpr.RegID, lpr.Reg,
SUM(c.[Weight]) AS LeftOffWt
FROM dbo.whsCo wc
INNER JOIN whsHe wh on wh.WhsHeaderID = wc.whsHeaderID
INNER JOIN dbo.cgtCo c ON c.[Consignment Reference] = wc.ConsignmentReference
INNER JOIN dbo.disCo dc on dc.ConsignmentRef = wc.ConsignmentReference
INNER JOIN dbo.genA ga ON ga.AddressID = c.Consignor
INNER JOIN dbo.lpra lp ON lp.Postcode = ga.PostcodePrefix
INNER JOIN dbo.lstPos lpr ON lpr.RegionID = lp.RegionID
AND c.Cancelled = 0
WHERE wc.StatusCode IN ('NL') and wh.ArrDepDate between @StartDate and @EndDate and dc.Description like '%failed%'
GROUP BY lpr.RegionID, lpr.Region
我收到此錯誤:無法對包含聚合或子查詢的表達式執行聚合函數。 –
@戴安娜。 。 。我的回答中沒有這樣的表達。這個代碼也沒有暗示任何這樣的表達。 –