Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Need Help with Simple Query

Author  Topic 

ross_gt
Starting Member

23 Posts

Posted - 2011-05-27 : 18:40:33
I keep getting this message:
Operand data type nvarchar is invalid for sum operator.

USE Customer_Analytics

SELECT [Ordered By], [Order Date (YYYYMMDD)], SUM([Extended Sales PMAR Amount]) AS GT_Revenue
FROM [Customer_Analytics].[CleanData].[0607080910_sorted]
WHERE [Ordered By] LIKE N'%GEORGIA TECH%'
AND [Order Date (YYYYMMDD)] >= '20100101' AND [Order Date (YYYYMMDD)] < '20110101';

slimt_slimt
Aged Yak Warrior

746 Posts

Posted - 2011-05-28 : 02:42:35
hi,
your field [Extended Sales PMAR Amount] is nvarchar data type and you need to cast it before performing sum operation.
e.g.:


select
sum(cast([Extended Sales PMAR Amount] as int)) as GT_Revenue
from
[Customer_Analytics].[CleanData].[0607080910_sorted]
Go to Top of Page
   

- Advertisement -