> <cfquery name="GetWomen"
>          datasource="#datasource#"
>          dbtype="ODBC">
> SELECT Gender, ContestantID
> FROM ContestantManager
> WHERE Gender = '2'
> </cfquery>
>
> <cfquery name="GetTotalPts"
>          datasource="#datasource#"
>          dbtype="ODBC">
> SELECT #GetWomen.ContestantID#, SUM (AdjPoints) as TOTALPTS, SUM
> (MoneyEarned) as TOTALMONEY
> FROM ResultsManager
> GROUP BY #GetWomen.ContestantID#
> ORDER BY SUM (AdjPoints) DESC
> </cfquery>

Can I point out the first obvious thing - just "process-wise" convert the
#'d fields to their values in the second query and then re-read it;

<cfquery name="GetTotalPts"
         datasource="#datasource#"
         dbtype="ODBC">
        SELECT 1, SUM (AdjPoints) as TOTALPTS, SUM
                (MoneyEarned) as TOTALMONEY
        FROM ResultsManager
        GROUP BY 1
        ORDER BY SUM (AdjPoints) DESC
</cfquery>

This makes no sense at all... the ContestantID is probably a number, so put
it on the side of a WHERE or HAVING, and don't treat it like a field name
unless it BECOMES a field name;

<cfquery name="GetTotalPts"
         datasource="#datasource#"
         dbtype="ODBC">
        SELECT ContestantID, SUM (AdjPoints) as TOTALPTS, SUM
                (MoneyEarned) as TOTALMONEY
        FROM ResultsManager
        GROUP BY ContestantID
        HAVING ContestantID in (#ValueList(GetWomen.ContestantID)#)
        ORDER BY SUM (AdjPoints) DESC
</cfquery>

Is probably what you want... Try it like this and see if it works

Philip Arnold
Director
Certified ColdFusion Developer
ASP Multimedia Limited
T: +44 (0)20 8680 1133

"Websites for the real world"

**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.
**********************************************************************



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to