Skip to content
Advertisement

SQL INNER JOIN of sum distinct values

I have 3 tables called musics, singers and playlistInfos. I want to get Top 10 listened England musics.What kind of sql query help me?

SELECT * FROM musics m INNER JOIN playlistInfo p ON p.musicID = m.id INNER JOIN singer a ON a.id = m.singerID GROUP BY p.musicID ORDER BY p.listened

I try this one but I did not get result what I was expecting.How can ı fix it?

Advertisement

Answer

Well first of all your sample data was wrong. So first lets create the right structure.

And please keep in mind, in future if you share sql scripts to create your sample data, you will get more answers.

And then query our tables for the top 10 singers from England.

Some little extra (if you want to get most listened song)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement