mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
wow
This commit is contained in:
parent
0f2e23bde2
commit
714a5de10f
1 changed files with 34 additions and 0 deletions
34
wow.sql
Normal file
34
wow.sql
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
SELECT *
|
||||||
|
FROM discord
|
||||||
|
LEFT JOIN (
|
||||||
|
SELECT DISTINCT ON (ma.discord_id)
|
||||||
|
ma.discord_id discord_id2,
|
||||||
|
fs.fav_song fav_song2,
|
||||||
|
ma.max_plays max_plays2
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
discord_id,
|
||||||
|
max(plays) max_plays
|
||||||
|
FROM
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
playedmusic.enqueuer_id discord_id,
|
||||||
|
playedmusic.filename fav_song,
|
||||||
|
count(*) plays
|
||||||
|
FROM playedmusic
|
||||||
|
GROUP BY playedmusic.filename, playedmusic.enqueuer_id
|
||||||
|
ORDER BY plays DESC
|
||||||
|
) play_counts
|
||||||
|
GROUP BY discord_id
|
||||||
|
) ma
|
||||||
|
INNER JOIN
|
||||||
|
(
|
||||||
|
SELECT
|
||||||
|
playedmusic.enqueuer_id discord_id,
|
||||||
|
playedmusic.filename fav_song,
|
||||||
|
count(*) plays
|
||||||
|
FROM playedmusic
|
||||||
|
GROUP BY playedmusic.filename, playedmusic.enqueuer_id
|
||||||
|
ORDER BY plays DESC
|
||||||
|
) fs ON fs.discord_id = ma.discord_id AND fs.plays = ma.max_plays
|
||||||
|
) fav_songs ON fav_songs.discord_id2 = discord.discord_id;
|
Loading…
Reference in a new issue