What was the error message you were getting?  IIRC, you can't use ali
ased
columns in your where clause, so you need to put your whole computati
on into
your where clause as well.  How's that for code reuse :)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: February 13, 2002 2:43 PM
To: CF-Talk
Subject: Re: How do u add colums in SQL query and do a WHERE on the n
ew
column


Was wondering if anyone knows how to add up 4 columns in a query, giv
e the
result a new column name, and then use that new column name in the WH
ERE
part of the query.

Situation is where some customers are 30, 60, 90 or 120 past due. So 
I'm
trying to add up the 30,60,90,120 column totals and save the result a
s a new
column called TOTALOUTSTANDING

Then we want to send emails to anyone where TOTALOUTSTANDING > 5   (w
here
the total outstanding is more than $5)

I tried this script, but the dang thing never worked:(

<CFQUERY NAME="pastduenotice" DATASOURCE="customers">
SELECT first_name, email_address, customer_number, total_due, (past_d
ue_30)
+ (past_due_60) + (past_due_90) + (past_due_120) AS totaloutstanding
FROM accountsreceivable
where totaloutstanding > 0
</CFQUERY>

Appreciate any enlightenment on this one:)
_____________________________________________________________________
_
Why Share?
  Dedicated Win 2000 Server � PIII 800 / 256 MB RAM / 40 GB HD / 20
 GB
MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionc
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation � $99/Month � Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to