I am trying to execute the following query in SQL Server:
Select *, sum(Quantity) as Quantity from tblDeal where buyercode = 25
and dealdate >= '2014/04/01' and dealdate <= '2015/03/31'
group by dealno order by DealDate, DealNo
and I am getting the following error:
ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]
Column 'tblDeal.dealid' is invalid in the select list because it is not
contained in either an aggregate function or the GROUP BY clause.
tbldeal.dealid is actually one of multiple columns present in the tbldeal table.
I have searched the internet for solutions but in most cases, people are suggesting to add the column to the group by clause or add an aggregate function.These maneuvers might remove the error but might affect the end result.My requirement is to keep the data grouped by dealno.What should I do? Kindly help.