Skip to content

Instantly share code, notes, and snippets.

@waltton
Last active November 7, 2022 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save waltton/fe064d3fd2ddd05980ab72e8a106ca97 to your computer and use it in GitHub Desktop.
Save waltton/fe064d3fd2ddd05980ab72e8a106ca97 to your computer and use it in GitHub Desktop.
-- after a while
SELECT pg_sleep(1);
-- I started to think about it again, cat owners will pay anything to make their cats happy
-- So let's make this at least 10% more expensive
UPDATE product
SET price = price * 1.1
, date_updated = NOW();
SELECT substring(id::text, 1, 5) || '...' AS id, name, to_char(price, '999D99') AS price, '... ' || substring(date_added::text, 12, 8) AS date_added, '... ' || substring(date_updated::text, 12, 8) AS date_updated FROM product;
-- id | name | price | date_added | date_updated
-- ----------+----------------------+---------+--------------+--------------
-- 3da19... | feather on the stick | 11.00 | ... 16:53:59 | ... 16:54:00
-- 156a6... | mouse on the stick | 13.20 | ... 16:53:59 | ... 16:54:00
-- 4ad03... | bed cavern | 152.90 | ... 16:53:59 | ... 16:54:00
-- 1612f... | scratch toy | 31.90 | ... 16:53:59 | ... 16:54:00
-- b9803... | loud bell ball | 8.80 | ... 16:53:59 | ... 16:54:00
-- (5 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment