example.sql 944 B

1234567891011121314151617181920
  1. -- Insert a tag if it got missed
  2. --INSERT INTO tags_map (transaction_id, tag_id) VALUES(2247, 11);
  3. -- Check your filter is correct first!
  4. SELECT * FROM transactions t
  5. LEFT JOIN tags_map ON (transaction_id = t.id)
  6. LEFT JOIN tags tg ON (tag_id = tg.id)
  7. WHERE transaction_id = 2247;
  8. -- Move from date to datej
  9. --UPDATE public.transactions
  10. -- -- Set the correct date on all rows that match the filter: Noon NZ time on 30 April 2024 (use exact time if known)
  11. -- SET ts=('2024-04-30 12:00'::timestamp with time zone AT TIME ZONE 'UTC')
  12. -- -- Filter to the rows you want to alter: Noon NZ time on 15 April 2024 (use exact time if knwon)
  13. -- WHERE ts::date = ('2024-04-15 12:00'::timestamp with time zone AT TIME ZONE 'UTC')::date;
  14. -- Check your filter is correct first!
  15. SELECT *, sum(price) OVER () FROM public.transactions
  16. WHERE ts::date = ('2024-04-15 12:00'::timestamp with time zone AT TIME ZONE 'UTC')::date and store_id = 8;