select shipname,sum(total)from Orders where bogus='No'
and year(Date)='2004' and orderID like 'MN%'
Group by shipname
order by shipName
It gives the following error:
Server: Msg 409, Level 16, State 2, Line 1
The sum or average aggregate operation cannot take a varchar data type as an argument.
The data type of total is varchar, so how can I sum the total?
Dig Deeper on SQL-Transact SQL (T-SQL)
Related Q&A from Greg Low
Should developers be granted permissions to production queue in a SQL Server environment? See why expert Greg Low suggests proc access by WITH ... Continue Reading
Find how to save stored procedure output to the network drive via SQL Server Management Studio. Continue Reading
Find how to query in SQL Server to get all database names created by users. Continue Reading