I have this running query:
SELECT DISTINCT
b.NAME AS [Service Name],
CASE
WHEN [a].[PAY_MODE_ID] IN ( 1, 2 ) THEN
'OFFLINE'
ELSE
'ONLINE'
END AS [Transaction Type],
p.NAME AS [Payment Method],
SUM(a.REQUESTED_QTY) AS [Transaction],
SUM(a.ITEM_TOTAL) AS Income
FROM dbo.BILL_INFO_DETAIL AS a
INNER JOIN dbo.SERVICE_INFO AS b
ON a.SERVICE_CODE = b.SERVICE_CODE
INNER JOIN dbo.PAY_MODE AS p
ON a.PAY_MODE_ID = p.PAY_MODE_ID
WHERE (a.INPUT_STATUS = '1')
AND (b.SERVICE_CODE IN ( 1610, 1611, 1612 ))
AND (CONVERT(VARCHAR(2), a.STAMP_DATE, 101) IN ( '10', '11', '12' ))
AND (CONVERT(VARCHAR(4), a.STAMP_DATE, 102) IN ( '2017' ))
AND (b.FEE > 1)
GROUP BY b.NAME,
CASE
WHEN [a].[PAY_MODE_ID] IN ( 1, 2 ) THEN
'OFFLINE'
ELSE
'ONLINE'
END,
p.NAME
ORDER BY [Transaction Type];
Linqer is not able to convert this to proper LINQ:
SQL syntax error: Each GROUP BY expression must contain at least one column reference.
This query is working in SQL Server. Any pointers?
Note:
- Removing the
DISTINCT
has no effect - Removing the
ORDER BY
has no effect - Removing the
;
has no effect
Seems that all I had to do was to remove the CASE with PAY_MODE_ID. I modified the query apart from that change in order to make it production ready:
This resulted in LINQ (slightly modified):