select distinct on ("date", location_pre, product_pre, type) "date", location_pre, product_pre, quantity, type, updated_atfrom transactions torder by t."date", t.location_pre, t.product_pre, t.type, t.updated_at desc
select distinct on ("date", location_pre, product_pre, type) "date", location_pre, product_pre, quantity, type, updated_atfrom transactions torder by t."date", t.location_pre, t.product_pre, t.type, t.updated_at desc