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 2000 Forums
 Transact-SQL (2000)
 How to apply aggregate functions to varchar column

Author  Topic 

sql_learner
Starting Member

7 Posts

Posted - 2002-08-13 : 08:09:08
Hi ALL

I want to apply an aggregate function like SUM on a column of type VARCHAR. SUM only works with numeric cols and I didn't know if there is any function or supporting technique to do that. Pls HELP!!!

THANKS!!

nr
SQLTeam MVY

12543 Posts

Posted - 2002-08-13 : 08:19:00
How do you sum a varchar?

sum(convert(int,charcol))

you can use max and min on varchars.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

jasper_smith
SQL Server MVP & SQLTeam MVY

846 Posts

Posted - 2002-08-13 : 08:23:07
Why are you using a varchar column to store numeric data that you want to perform numeric operations on ?



HTH
Jasper Smith
Go to Top of Page

macka
Posting Yak Master

162 Posts

Posted - 2002-08-13 : 08:30:27
Do you wish to concatenate a number of strings into a single string ? If so, then take a look at this :

[url]http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=15651[/url]

macka.

Go to Top of Page

sql_learner
Starting Member

7 Posts

Posted - 2002-08-14 : 00:10:14
Thanks Macka! Your link really resolved my problem. It was that I wanted to concatenate the string cols, not applying a SUM on it.
Thanks again

Go to Top of Page
   

- Advertisement -