Skip to main content
Known Participant
June 22, 2007
Question

Group By issues

  • June 22, 2007
  • 3 replies
  • 407 views
hi..
I have a query which groups the result output to show all the songs contained on a specific album....I am also showing the amount of comments each song has by using COUNT in the select section of the query...

thus..my code is

<!---count number of songs--->
<cfquery name="song_count" datasource="#application.datasource#">
SELECT name_sng, id_sng, rec_rcd, COUNT(content_msg) as me_co
FROM (record_rcd
RIGHT OUTER JOIN song_sng
on record_rcd.id_rcd = song_sng.id_rcd_sng)
LEFT OUTER JOIN messages_msg
ON song_sng.id_sng = id_sng_msg
WHERE id_art_rcd = #id_art.id_art#
GROUP BY name_sng
</cfquery>

and the output is

<cfoutput query="song_count" group="rec_rcd">
#rec_rcd#
<cfoutput>
<p>
#name_sng# - #me_co# comments</a>
</p>
</cfoutput>
</cfoutput>

the thing is, that i cannot get the songs to group by album properly

see here

http://www.musicexplained.co.uk/a/home_2.cfm

if I remove the COUNT(content_msg) as me_co and the GROUP BY clause, the songs group by album as expected..

just wondering what im doing wrong...any help would be massively appreciated
This topic has been closed for replies.

3 replies

namtaxAuthor
Known Participant
June 24, 2007
thatsa cf...thats worked

briliiant!!
Inspiring
June 23, 2007
To properly group the results, order by that column first . Then any other columns you want.

ORDER BY rec_rcd, other columns ..
namtaxAuthor
Known Participant
June 22, 2007