• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Group By issues

New Here ,
Jun 22, 2007 Jun 22, 2007

Copy link to clipboard

Copied

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
TOPICS
Advanced techniques

Views

315

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 22, 2007 Jun 22, 2007

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Jun 23, 2007 Jun 23, 2007

Copy link to clipboard

Copied

To properly group the results, order by that column first . Then any other columns you want.

ORDER BY rec_rcd, other columns ..

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 24, 2007 Jun 24, 2007

Copy link to clipboard

Copied

LATEST
thatsa cf...thats worked

briliiant!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation