I use timestamp(3) with time zone
in my database for the tables when one is necessary, this is almost any case in my situation.
I need to select all columns of a table possibly in a much more complex query than the following.
My question is how to get the timestamps (with time zone) at the desired time zone with SQL at time zone '<TIMEZONE>'
for a select expression like q.*
one of which is the timestamp (with time zone) column.
I might have subqueries with the same situation.
Is there an expression to achieve this for query wide?
SELECT
q.*, -- created_at timestamp (with time zone) is already in here
q.created_at AT TIME ZONE 'EET', --instead of this redundant column selection
u.name AS author,
u.reputation,
CASE WHEN count(t.*)=0 THEN '[]' ELSE json_agg(t.*) END as tags
FROM posts q
-- authors
JOIN users u
ON q.author_id = u.id
-- tags
left join post_has_tag p_h_t
on q.id = p_h_t.post_id
left join tags t
on p_h_t.tag_id = t.id
WHERE q.post_type = 'question'
group by q.id, u.id;