Created
April 1, 2016 14:16
-
-
Save graham-thomson/2c0da4ece10271c19116201772c271f6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--Create a temp table with a sample of recent daily pivot date (Note: TEMP TABLEs only exist for the duration of your connection to the database.)-- | |
CREATE TEMP TABLE sample_daily AS(SELECT * FROM adobe_data.dat_daily_pivot WHERE sample_start_date <= '2016-03-30' ORDER BY sample_start_date DESC LIMIT 100); | |
--Check initial total_sales sum-- | |
SELECT SUM(total_sales) FROM sample_daily; | |
-->>1800.2825 | |
--Update <table_name> SET <col_name> = <what you want to update the column to> WHERE <where clause>-- | |
UPDATE sample_daily SET total_sales = total_sales * 4 WHERE sample_start_date <= '2016-03-30'; | |
--Check update total sales-- | |
SELECT SUM(total_sales) FROM sample_daily; | |
-->>7201.1300 | |
--QA-- | |
SELECT (1800.2825 * 4)::numeric; | |
-->>7201.1300 | |
--Ready to do on production table-- | |
UPDATE adobe_data.dat_daily_pivot SET total_sales = total_sales * 4 WHERE sample_start_date <= '2016-03-30'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment