This is the query I try to run:
Select Status from [transaction] where TransactionID IN (select MAX(CAST(TransactionID AS VARCHAR(36))), sum(debit)
FROM [transaction]
WHERE dbo.getday(StartSaleTime) >= '5/1/2011' and dbo.getday(StartSaleTime) <= '5/3/2011' and Status > -1 And TransactionNo like 'EL%' And TransactionType = 4
GROUP BY CustomerID, debit HAVING ( COUNT(CustomerID) > 1 ))
it returns this error:
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
It tells you exactly what is wrong in the error message. When using
inyou can only specify one column in the select list.If you change your query to this, it should work fine.
You can specify multiple columns but only when using EXISTS not
IN