Created
September 12, 2018 00:56
-
-
Save joebartels/06658384afbf2f182b30cc89f0e3fea8 to your computer and use it in GitHub Desktop.
updating table entries with subquery
This file contains hidden or 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
with date_fields as ( | |
select id, | |
extract(dow from date) as day_of_week, | |
extract(hour from date) as hour_of_day, | |
extract(minute from date) as minute_of_hour | |
from cycling_entry | |
) | |
update cycling_entry | |
set day_of_week=subquery.day_of_week, | |
hour_of_day=subquery.hour_of_day, | |
minute_of_hour=subquery.minute_of_hour | |
from ( | |
select * from date_fields | |
) as subquery | |
where cycling_entry.id = subquery.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment