Created
September 19, 2022 18:53
-
-
Save JorgeMichelena/70cdf57a6478cd7a5b1a775faef468e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT "targets_user"."id", "targets_user"."password", | |
... | |
"targets_user"."date_of_birth", "targets_user"."zodiac_sign", | |
(COUNT(DISTINCT "targets_match"."id") + COUNT(DISTINCT T4."id")) AS "match_count" | |
FROM "targets_user" | |
LEFT OUTER JOIN "targets_target" | |
ON ("targets_user"."id" = "targets_target"."user_id") | |
LEFT OUTER JOIN "targets_match" | |
ON ("targets_target"."id" = "targets_match"."target_1_id") | |
LEFT OUTER JOIN "targets_match" T4 | |
ON ("targets_target"."id" = T4."target_2_id") | |
GROUP BY "targets_user"."id" | |
ORDER BY "match_count" DESC LIMIT 21 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment