Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting variables Problem

Status
Not open for further replies.

acewilli

IS-IT--Management
Apr 11, 2003
98
US
I am using ASP with VBScript. The code below does not work at all. What is the correct way to use an aggregate function in order to set the results of it to a variable? Please....anyone? I'm begging. I've tried everything. Thank you.

Code:
strtotal = "Select cast(sum(npoints) as decimal) from team"
Set rsTotal = Server.CreateObject("ADODB.Recordset")
rsTotal.open strtotal, db
 
So, you simply want rsTotal.Fields(0) ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Do you really need to cast as decimal?
Code:
strtotal = "Select sum(npoints) from team"
 
no I do not have to cast as decimal although I don't want something such as this 10.0 I would like 10 instead. Either way though. No big deal. The problem is that when I do it the way you suggest xwb is that it just returns Select sum(npoints) from team rather than the actual SUM of that column. Not sure what is going on with it. Any other ideas? I sure do appreciate it.

Thanks,

acewilli
 
PHV & XWV...here is what I finally got to work. Could either of you tell me why this would work and the other ways would not?

Code:
set rs=db.execute ("Select SUM(npoints) as strtotal from team ")

Thank you both for everything.

acewilli
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top