Jelajahi Sumber

add examples

Daniel Sheffield 6 bulan lalu
induk
melakukan
3a22ea46a4
1 mengubah file dengan 14 tambahan dan 0 penghapusan
  1. 14 0
      example.sql

+ 14 - 0
example.sql

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