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
Find how to query in SQL Server to get all database names created by users. Continue Reading
Different SQL Server versions can be installed on one machine, learn how and get the best practices for SQL Server installation and compatibility. Continue Reading
Triggers in SQL Server can be executed before a table is updated. Get triggers to read and extract table values before and after the table is updated. Continue Reading