(SELECT
substr(day::text, 0, 11) AS timestamp,
'prev_day' AS direction
FROM socrata.daily_diff
WHERE day < '2022-11-05 00:00:00'::timestamp
ORDER BY day DESC LIMIT 1)
UNION ALL
(SELECT
substr(day::text, 0, 11) AS timestamp,
'next_day' AS direction
FROM socrata.daily_diff
WHERE day > '2022-11-05 00:00:00'::timestamp
ORDER BY day ASC LIMIT 1)
UNION ALL
(SELECT
substr(day::text, 0, 11) AS timestamp,
'equivalent_day' AS direction
FROM socrata.daily_diff
WHERE day <= '2022-11-05 00:00:00'::timestamp
ORDER BY day DESC LIMIT 1)
UNION ALL
(SELECT
substr(week::text, 0, 11) AS timestamp,
'prev_week' AS direction
FROM socrata.weekly_diff
WHERE week < '2022-11-05 00:00:00'::timestamp
ORDER BY week DESC LIMIT 1)
UNION ALL
(SELECT
substr(week::text, 0, 11) AS timestamp,
'next_week' AS direction
FROM socrata.weekly_diff
WHERE week > '2022-11-05 00:00:00'::timestamp
ORDER BY week ASC LIMIT 1)
UNION ALL
(SELECT
substr(week::text, 0, 11) AS timestamp,
'equivalent_week' AS direction
FROM socrata.weekly_diff
WHERE week <= '2022-11-05 00:00:00'::timestamp
ORDER BY week DESC LIMIT 1)
UNION ALL
(SELECT
substr(month::text, 0, 11) AS timestamp,
'prev_month' AS direction
FROM socrata.monthly_diff
WHERE month < '2022-11-05 00:00:00'::timestamp
ORDER BY month DESC LIMIT 1)
UNION ALL
(SELECT
substr(month::text, 0, 11) AS timestamp,
'next_month' AS direction
FROM socrata.monthly_diff
WHERE month > '2022-11-05 00:00:00'::timestamp
ORDER BY month ASC LIMIT 1)
UNION ALL
(SELECT
substr(month::text, 0, 11) AS timestamp,
'equivalent_month' AS direction
FROM socrata.monthly_diff
WHERE month <= '2022-11-05 00:00:00'::timestamp
ORDER BY month DESC LIMIT 1)