Created
January 24, 2023 21:03
-
-
Save marcomalva/b61365c9d5e4fe863fb12e69df65e375 to your computer and use it in GitHub Desktop.
[PSQL - Select Next Event From Today]Use CTE to supplement time zone from another table #psql
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
WITH tz AS ( | |
SELECT gc.value AS tzv FROM public.gv_config gc WHERE gc.name = 'arena.timezone' LIMIT 1 | |
) | |
SELECT | |
id | |
, (NOW() AT TIME ZONE tz.tzv) now_arena | |
, (NOW() AT TIME ZONE tz.tzv)::date now_arena_date | |
FROM | |
public.event_details ed | |
, tz tz | |
WHERE | |
ticketing_ids @> (ARRAY['EV23LAV1'])::text[] | |
AND (id >= (NOW() AT TIME ZONE tz.tzv)::date) | |
ORDER BY | |
id, venue | |
LIMIT 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment