Question : Sum totals from a table and group results

Good Day Everyone!!! I have yet another calculation problem within Coldfusion. I'm just having troubles wrapping my head around this, but I have a table with 300 records related to commited costs of a project. There may only be 9 projects, bust several commited costs to each one. I need to be able to total the commited costs per project number, and then display on my web page through a loop the total commited cost of eash project....so my web page would only have 9 projects listed with the totlas calculated from the project table. Below is where I'm at, which is nowhere close.

<CFQUERY DATASOURCE="MCA_Oracle" NAME="JONOLoopList">
    SELECT DISTINCT BUDGET.JONO, BUDGET.FY,
      
(SELECT SUM(BUDGET.AMOUNT_COMMITED) AS COMMITED FROM MCA.BUDGET)
FROM MCA.BUDGET
</CFQUERY>

My initial error is that the Element COMMITED is undefined in JONOLOOPLIST.  Any help would be greatly appreciated.

Answer : Sum totals from a table and group results

>> (SELECT SUM(BUDGET.AMOUNT_COMMITED) AS COMMITED FROM MCA.BUDGET)

It's because column alias is in the wrong place. It should probably be:

   (SELECT SUM(BUDGET.AMOUNT_COMMITED) FROM MCA.BUDGET) AS COMMITED

BUT ... I'm not sure why it's a subquery.  I was expecting something more like

    SELECT BUDGET.JONO, BUDGET.FY, SUM(BUDGET.AMOUNT_COMMITED) AS COMMITED
    FROM MCA.BUDGET
    GROUP BY BUDGET.JONO, BUDGET.FY
Random Solutions  
 
programming4us programming4us