select s1.id, s1.title, s1.username, sum(plv.view_count) sumc from (SELECT DISTINCT pl.id, pl.title, u.username from playlist pl, user u, segment s, playlistsegs pls where pl.id=pls.playlist_id and pls.segment_id=s.id and s.media_id=10051 and pl.author_id=u.id and pl.deleted=false and pl.submitted=true) s1 LEFT JOIN playlistviews plv ON s1.id=plv.playlist_id group by s1.id order by sumc desc LIMIT 0, 20
|