that is strange.  Have you tried the HAVING clause instead of WHERE?

----- Original Message -----
From: "Daniel Quinones" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Thursday, February 14, 2002 6:24 PM
Subject: Strange Query of Query Behavior


> Hello,
>
> I am doing a query that extracts all sales info for an employee in a
> particular time frame.
>
> Then I am doing 2 querys of that query as seen:
>
> <cfquery name="SalesCalc1" dbtype="query">
> SELECT SalesAmount AS Sales1Sum FROM SalesQuery Where BonusDeal =
> 1</cfquery>
> <cfquery name="SalesCalc2" dbtype="query">
> SELECT SalesAmount AS Sales2Sum FROM SalesQuery Where BonusDeal =
> 0</cfquery>
>
> This is working correctly, showing 2 different (correct) values for the
> amounts.
>
> Sales1Sum: 10,000
> Sales2Sum: 15,000
>
> But, when I want to use the SUM function in the SQL it shows totals for
both
> as the same total.
>
> <cfquery name="SalesCalc1" dbtype="query">
> SELECT SUM(SalesAmount) AS Sales1Sum FROM SalesQuery Where BonusDeal =
> 1</cfquery>
> <cfquery name="SalesCalc2" dbtype="query">
> SELECT SUM(SalesAmount) AS Sales2Sum FROM SalesQuery Where BonusDeal =
> 0</cfquery>
>
> Sales1Sum: 25,000
> Sales2Sum: 25,000
>
> So it appears that the Query of Query is not taking the WHERE clause into
> consideration......
>
> Any Ideas on why?  Is this a Bug?  How should I proceed?
>
> Thanks Everyone,
>
> -Dan
> 
______________________________________________________________________
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