Sorry,   forgot to include the revised script ...
 =============  ============  ===========

OK,  think I've got it now ...
GROUP BY  contains the main criteria for the query  (not to be confused with 
ORDER BY)
HAVING  should contain any (both) conditions needed for the search.

http://ttcfm.open.ac.uk/~bs3578/test1/Week9_Act6.cfm


<CFquery name="DeptAverage" datasource="bs3578" >
    SELECT  a.Amount AS aAmount,
                    d.DeptName AS dName,
                    AVG(a.Amount) AS  AverageAward,
                    SUM(a.Amount) AS  DeptTotal
  FROM  incentiveawards a
           INNER JOIN  employeedirectory e ON (e.ID = a.RecipientIDfk)
           INNER JOIN  departments d  ON (d.DepartmentID = e.DepartmentIDfk)
  GROUP BY  a.Amount
  HAVING  SUM(a.Amount) > 5000 AND AVG(a.Amount) > 3000
  ORDER BY  d.DeptName DESC;
</CFquery>




~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:320888
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to