House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home / Groups / ColdFusion Newbie (CF-Newbie)

Get and Display Average

Author:
Adam Parker
03/15/2010 03:59 PM

Hello - I am trying to display the average rating for poems that have been reviewed.  On he poemOverview page, the poems are rated 1-5.  When the form submits successfully, the poemID, rating, and the current user gets recorded to the poemRatings table.  The user is redirected to the poemDashboard page. On the poemDashboard page, all poems are listed and called from the poems table.   I want to include a column in the output for the average rating of the poem: ID         Poem Title             Avg. Rating           Judge I am unsure how to created a query that gets the average rating for each poem to list on the poemDashboard page.  I have tried the following query but the average rating displays for every poem: <!---Get Poems' Average ratings---> <cfquery name="qGetRatings" datasource="#request.dsn#" result="getRatingsResult">   SELECT     CAST(AVG(pr.rating) AS numeric(12,2)) AS avgRating   FROM     ratings pr   LEFT OUTER JOIN poems p ON pr.poemID = p.id   GROUP BY  pr.poemID </cfquery> How may I accomplish this? Thanks, Adam


Search cf-newbie

February 11, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
       1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29