I am just running a basic query on Retool to show sales growth MoM, I'm currently bumping into an issue - the same query gives me different results on Dbeaver (the DB Tool I am using) and ReTool. The differences are not massive but it still bothers me that the same query results in two different numbers.
Any tips on how to resolve this / ideas of what could be causing it?
SELECT
date_trunc('month',a.created_at)::DATE "date",
SUM((a.original_amount)::float/100),
count(distinct a.id) "booking_count"
from
booking_activitybooking a
LEFT JOIN
marketplace_activity act on a.activity_id = act.id
LEFT JOIN
marketplace_supplier s on act.supplier_id = s.id
group by
date_trunc('month',a.created_at)::DATE
Google suggests that the use_server_time_zone option in DBeaver may be the culprit here.
If the timezone is different between client and server then your date_trunc functions may be the discrepancy.
Thank you! Turns out Dbeaver had the wrong timezone, and so does Retool .
I have finally managed to change the one in DBeaver but can't see a way to set a default timezone in ReTool - is that correct?
You could try using SET SESSION timezone TO 'YOUR REGION GOES HERE';
before running your query, seems to work on my retool db and returns a timezone offset, eg: SET SESSION timezone TO 'America/Denver'; SELECT EXTRACT(TIMEZONE FROM now());
Hope this helps