From a3dda94db49570f7f1e6484b49bca9196c317493 Mon Sep 17 00:00:00 2001
From: Dennis Kobert <dennis@kobert.dev>
Date: Fri, 19 Feb 2021 11:07:39 +0000
Subject: Fix sql code

---
 sql/new.sql | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
 create mode 100644 sql/new.sql

(limited to 'sql/new.sql')

diff --git a/sql/new.sql b/sql/new.sql
new file mode 100644
index 0000000..57d918b
--- /dev/null
+++ b/sql/new.sql
@@ -0,0 +1,18 @@
+WITH users AS (
+            SELECT *
+			    FROM ( VALUES ('dennis'), ('caitriao') ) AS _ (user_id)
+			)
+			SELECT track_id, name, artist
+			FROM track
+			JOIN (
+	        SELECT track_id
+			FROM user_track
+			JOIN suser USING (user_id)
+			JOIN track USING (track_id)
+            JOIN lobby USING (lobby_id)
+			WHERE suser.user_name IN (SELECT user_name FROM users) AND token = 'shnPcxQ7REwF3QL1T65mcqPtf3k='
+			GROUP BY track_id
+			HAVING COUNT(track_id) = (SELECT COUNT(*) FROM users)
+			ORDER BY SUM(score) DESC
+			) AS _ USING (track_id)
+			;
-- 
cgit v1.2.3-70-g09d2

