Last active
May 3, 2020 07:53
-
-
Save motionrus/a40e36ffc11826c038881e41011c08a4 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 "api_thread"."id", | |
"api_thread"."conference_id", | |
"api_thread"."title", | |
"api_thread"."description", | |
"api_thread"."is_closed", | |
"api_thread"."is_pinned", | |
"api_thread"."post_moderation_allowed", | |
"api_thread"."has_voting", | |
"api_thread"."created_at", | |
"api_thread"."expired", | |
"api_thread"."owner_id", | |
"api_thread"."sv", | |
(SELECT U0."clear_content" | |
FROM "api_post" U0 | |
WHERE U0."thread_id" = ("api_thread"."id") | |
ORDER BY U0."created" DESC | |
LIMIT 1) AS "last_post" | |
FROM "api_thread" | |
SELECT at.*, ap.* | |
FROM api_thread at | |
LEFT JOIN api_post ap ON at.id = ap.thread_id | |
WHERE ap.created IN (SELECT max(created) | |
FROM api_thread at | |
LEFT JOIN api_post ap ON at.id = ap.thread_id | |
GROUP BY at) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment