Created
March 1, 2021 14:20
-
-
Save Pomeha/935db63087343165a5e132beb51a3171 to your computer and use it in GitHub Desktop.
Limit by record type on table
This file contains hidden or 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 * FROM | |
( | |
SELECT (CASE WHEN post_id IS NOT NULL THEN ROW_NUMBER() OVER (PARTITION BY (post_id IS NOT NULL)::integer) END) AS r_post, | |
(CASE WHEN event_id IS NOT NULL THEN ROW_NUMBER() OVER (PARTITION BY (event_id IS NOT NULL)::integer) END) AS r_event, | |
t.* | |
FROM feed_items t) | |
feed_items | |
WHERE r_post <= VALUE OR r_event <= VALUE; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment