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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Total the numbers in the database

Status
Not open for further replies.

jessc

Programmer
Jul 18, 2005
11
US
Hi,

I'm pulling numbers from a database. How can I pull two numbers from the database but instead of showing both numbers, showing the TOTAL of these two numbers? Currently my cfquery statement looks like this (This pulls one number at a time):

<cfquery name="get23" datasource="#application.dsn#">
select *
from tblA
where typeId = '1' and phaseId = '1' and yearid between '#begMonth#' and '#endMonth#'
order by yearmthId
</cfquery>

And then I pull the data in like this:

<cfif #get23.recordcount# gte 1>
<td><cfinput name="INS" type="Text" value="#get23.ins#" size="3" tabindex="1" Required="Yes" message="Do Over" validate="integer"></td>
<cfelse>
<td><cfinput name="INS" type="Text" value="" size="3" tabindex="1" Required="Yes" message="Do Over" validate="integer"></td>
</cfif>

How can I pull two numbers from the database, and only show their total, not their significant numbers?

THanks in advance for any help.

Jess
 
select field1+field2 as your total

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
select field1+field2 as yourtotal

We've heard that a million monkeys at a million keyboards could produce the complete works of Shakespeare; now, thanks to the Internet, we know that is not true.
 
TruthInSatire,

THanks for offering your expertise. The reason why the Select field1+field2 didnt work is because the field name is the same. However, the numbers are differentiated by the Typeid. In the query above, the typeid = 1. That pulls one number, let's say 100 (as an example). Typeid = 2 will pull the number 500. How would I pull both typeid...and show only the number 600?

Thanks again,

Jess
 
select sum(field1) as total
from tblA
where typeId in ( 1 , 2 )
and phaseId = '1'
and yearid between '#begMonth#' and '#endMonth#'

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top