<!--- Retrieve summarized expense data from database --->
<CFQUERY NAME="GetExp" DATASOURCE="#REQUEST.DataSource#">
  SELECT 
    f.FilmID, f.MovieTitle,
    SUM(ExpenseAmount) AS ExpenseSum
  FROM Expenses e, Films f
  WHERE e.FilmID = f.FilmID
  GROUP BY f.FilmID, f.MovieTitle
  ORDER BY f.MovieTitle
</CFQUERY>


<HTML>
<HEAD><TITLE>Film Expenses</TITLE></HEAD>
<BODY>
<H2>Expense Overview</H2>

<!--- Output film-level expense summary --->
<CFTABLE 
  QUERY="GetExp" 
  HTMLTABLE="Yes" 
  BORDER="Yes" 
  COLHEADERS="Yes">

  <CFCOL 
    HEADER="Film Title" 
    TEXT="#MovieTitle#">
  <CFCOL 
    HEADER="Amount" 
    TEXT="#LSCurrencyFormat(ExpenseSum)#" 
    ALIGN="RIGHT">

</CFTABLE>

</BODY>
</HTML>