June 13, 2014 at 2:13 am
Hi,
I am using the below query for calculation and I get this error.
Operand data type nvarchar is invalid for sum operator.
'$ '+ REVERSE(SUBSTRING(REVERSE(CONVERT(varchar,(CAST(round(isnull(sum(t7.[Pre Override Cost]),0),0) as money) + 1 -
cast(round(isnull(sum(t8.[Shared Dollars]),0),0)as money)),1)),4,255)) as [PreOverride L2],
'$ '+ REVERSE(SUBSTRING(REVERSE(CONVERT(varchar,(CAST(round(isnull(sum(t7.[Post Override Cost]),0),0) as money) -
cast(round(isnull(sum(t8.[Shared Dollars]),0),0)as money)),1)),4,255)) as [PostOverride L2]
June 13, 2014 at 2:26 am
what is the data type for Pre Override Cost, Shared Dollars?
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
June 13, 2014 at 3:13 am
Its numeric datatype
June 13, 2014 at 3:32 am
hmmmm...works ok for me
DECLARE @poc AS numeric(18,8)
DECLARE @sd AS numeric(18,8)
SET @poc = 123.456789
SET @sd = 99.533
SELECT
'$ '+ REVERSE(SUBSTRING(REVERSE(CONVERT(varchar,(CAST(round(isnull(sum(@poc),0),0) as money) + 1 -
cast(round(isnull(sum(@sd),0),0)as money)),1)),4,255)) as [PreOverride L2],
'$ '+ REVERSE(SUBSTRING(REVERSE(CONVERT(varchar,(CAST(round(isnull(sum(@poc),0),0) as money) -
cast(round(isnull(sum(@sd),0),0)as money)),1)),4,255)) as [PostOverride L2]
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
June 13, 2014 at 3:47 am
I am really sorry, its money datatype.
Preoverride, postoverride and shared dollar values will be like this $ 3, 456
June 13, 2014 at 4:06 am
vigneshkumart50 (6/13/2014)
I am really sorry, its money datatype.Preoverride, postoverride and shared dollar values will be like this $ 3, 456
still works as money.....did you try it in the code I provided?
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
June 13, 2014 at 4:15 am
I ran your code and I got this error.
Operand data type nvarchar is invalid for sum operator.
June 13, 2014 at 4:27 am
/*this works*/
DECLARE @poc1 AS money
DECLARE @poc2 AS money
DECLARE @sd AS money
/*this doesnt*/
--DECLARE @poc1 AS nvarchar(18)
--DECLARE @poc2 AS nvarchar(18)
--DECLARE @sd AS nvarchar(18)
SET @poc1 = 123.456789
SET @poc2 = 113.444
SET @sd = 99.533
SELECT
'$ '+ REVERSE(SUBSTRING(REVERSE(CONVERT(varchar,(CAST(round(isnull(sum(@poc1),0),0) as money) + 1 -
cast(round(isnull(sum(@sd),0),0)as money)),1)),4,255)) as [PreOverride L2],
'$ '+ REVERSE(SUBSTRING(REVERSE(CONVERT(varchar,(CAST(round(isnull(sum(@poc2),0),0) as money) -
cast(round(isnull(sum(@sd),0),0)as money)),1)),4,255)) as [PostOverride L2]
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
June 13, 2014 at 5:28 am
still the same error.
Operand data type nvarchar is invalid for sum operator.
June 13, 2014 at 5:38 am
can you post all the code you are running when you get the error
________________________________________________________________
you can lead a user to data....but you cannot make them think
and remember....every day is a school day
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply