average

SQL JOIN two tables with AVG

六月ゝ 毕业季﹏ 提交于 2020-12-23 12:16:31
问题 I am trying to join two tables: songs id | song | artist ---|------|------- 1 | foo | bar 2 | fuu | bor 3 | fyy | bir score id | score ---|------ 1 | 2 2 | 4 3 | 8 2 | 6 3 | 2 using this SQL command: SELECT songs.id, songs.song, songs.artist, score.score FROM songs LEFT JOIN score ON score.id=songs.id ORDER BY songs.id, score DESC What I get back is duplicates of the same song with multiple scores, I would like the score to be averaged. result id | song | artist | score ---|------|--------|--

SQL JOIN two tables with AVG

一个人想着一个人 提交于 2020-12-23 12:14:27
问题 I am trying to join two tables: songs id | song | artist ---|------|------- 1 | foo | bar 2 | fuu | bor 3 | fyy | bir score id | score ---|------ 1 | 2 2 | 4 3 | 8 2 | 6 3 | 2 using this SQL command: SELECT songs.id, songs.song, songs.artist, score.score FROM songs LEFT JOIN score ON score.id=songs.id ORDER BY songs.id, score DESC What I get back is duplicates of the same song with multiple scores, I would like the score to be averaged. result id | song | artist | score ---|------|--------|--