Q
Problem solve Get help with specific problems with your technologies, process and projects.

Varchar column errors

SQL Server Development expert Greg Low troubleshoots the error message, "The sum or average aggregate operation cannot take a varchar data type as an argument".

I am trying to execute the following:

select count(adj_code), adj_code, adj_desc, sum(amount) from REPORT_ADJUSTMENT WITH(NOLOCK) inner join REF_ADJUSTMENT_CODES...

on REPORT_ADJUSTMENT.adjustment_code = REF_ADJUSTMENT_CODES.adj_code

But receive the following:
"The sum or average aggregate operation cannot take a varchar data type as an argument"

It appears that the "amount" column is actually a varchar column. Perhaps try changing it to something like SUM(CAST(amount AS decimal(18,2)) instead of SUM(amount) if it's definitely a numeric value. I've just used decimal(18,2) as an example, you need to pick something appropriate.

View questions and answers from all of our SQL Server experts here.

This was last published in March 2006

Dig Deeper on SQL-Transact SQL (T-SQL)

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close