Acct Period F_year AmtDetf 1 2011 NullDetf 2 2011 NullDetf 3 2011 1669.57FTE 1 2011 3205.11FTE 2 2011 0FTE 3 2011 NullI created a query like:
Select Acct,Period,F_year, Sum(AMT) as Amtfrom dbo.CosGroup By Acct,Period,F_yearWhere Amt is not nullBut i am acquiring this error:
Msg 8117, Level 16, State 1, Line 1Operand also data kind varchar is invalid for amount operator.Can anyone aid me?
Try doing this:
Select Acct,Period,F_year, Sum(isnull(cast(AMT as float),0)) as Amtfrom dbo.CosGroup By Acct,Period,F_year
Apparently, the value "1669.57" is a string. So what does it mean to add this value to another?
The error message is correct: It"s not valid to include text worths together. If it was valid, I could not tell what the result need to be.
You are watching: Operand data type varchar is invalid for sum operator
You should either readjust your column type to a numeric type, or convert it somejust how prior to trying to include it.
If Amt is intfinished to be provided for mathematical operations, then it must be kind Decimal and also not varchar.
Thanks for contributing a solution to Stack Overflow!Please be sure to answer the question. Provide details and also share your research!
But avoid …Asking for aid, clarification, or responding to various other answers.Making statements based on opinion; back them up via references or personal experience.
See more: Many People Infected With Tapeworms May Be Unaware Of The Infection Due To A Lack Of Symptoms.
To learn more, watch our tips on writing excellent answers.
Message Your Answer Discard
Not the answer you're looking for? Browse various other concerns tagged sql sql-server sql-server-2008 tsql or ask your own question.
how to formulate tsql query for Avg of multiple rows of a column based upon matching to a worth in a second column?
website design / logo © 2021 Stack Exreadjust Inc; user contributions licensed under cc by-sa. rev2021.9.10.40187