Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access_asp thread: Getting a value from an aggregate function in a SQL statement


Message #1 by "Rick Lull" <ricklull@h...> on Thu, 20 Jun 2002 18:05:19
I'm using the following SELECT statement to extract the SUM total of 3 
columns of information from an Access database:

strSQL = "SELECT (SUM(orderamount) - SUM(oshipcost) - SUM
(CouponDiscount)) FROM orders WHERE Oaffid =" & AFID & " AND odate >= 
#1/1/2002# AND odate <= #1/31/2002#"

Now, where is the result of this query stored and how do I assign a 
variant to it? I can't use the traditional objRS.FieldName because I 
added the total of 3 fields. - Thanks.
Message #2 by "Charles Mabbott" <aa8vs@m...> on Thu, 20 Jun 2002 13:06:57 -0400
You might want to review the following:

http://www.aspfaq.com/show.asp?id=2159

Regards,
Chuck


>From: "Rick Lull" <ricklull@h...>
>Reply-To: "Access ASP" <access_asp@p...>
>To: "Access ASP" <access_asp@p...>
>Subject: [access_asp] Getting a value from an aggregate function in a SQL 
>statement
>Date: Thu, 20 Jun 2002 18:05:19
>
>I'm using the following SELECT statement to extract the SUM total of 3
>columns of information from an Access database:
>
>strSQL = "SELECT (SUM(orderamount) - SUM(oshipcost) - SUM
>(CouponDiscount)) FROM orders WHERE Oaffid =" & AFID & " AND odate >
>#1/1/2002# AND odate <= #1/31/2002#"
>
>Now, where is the result of this query stored and how do I assign a
>variant to it? I can't use the traditional objRS.FieldName because I
>added the total of 3 fields. - Thanks.




"If your not part of the solution,
there is good money to be made
prolonging the problem."


http://peleus.dhs.org:81/aa8vs


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx

Message #3 by "Ken Schaefer" <ken@a...> on Fri, 21 Jun 2002 14:22:59 +1000
You can use the ordinal position:

Response.Write(objRS(0))
Response.Write(objRS(1))

etc

or you can assign an alias in your query:

SELECT COUNT(field1) AS FieldCount FROM table1

Cheers
Ken

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
From: "Rick Lull" <ricklull@h...>
Subject: [access_asp] Getting a value from an aggregate function in a SQL
statement


: I'm using the following SELECT statement to extract the SUM total of 3
: columns of information from an Access database:
:
: strSQL = "SELECT (SUM(orderamount) - SUM(oshipcost) - SUM
: (CouponDiscount)) FROM orders WHERE Oaffid =" & AFID & " AND odate >
: #1/1/2002# AND odate <= #1/31/2002#"
:
: Now, where is the result of this query stored and how do I assign a
: variant to it? I can't use the traditional objRS.FieldName because I
: added the total of 3 fields. - Thanks.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


  Return to Index