sql - Updating timestamp column by adding value from other column -
scenario :
we have table:
game_played (id , start, game_duration )
in ui show id, starttime, finish time. ( earlier finish time calculated adding starttime + game duration)
(start , finish_time of timestmap in postgres. game_ruation of type : integer , shows seconds)
now due requirement change adding column : finish_time. for older data want update existing table populate values in finish_time
so trying this.
if write staement :
select start, start+ interval 60 seconds end game_played finish_time id = 123
this works.
if write
select start, start + interval ( select game_duration game_played id = 123) finish_time game_played id = 123
query doesn't work. can 1 please tell me missing or doing wrong?
try this:
select start, start + game_duration * interval '1 seconds' finish_time "game_played" id = 123;
btw: there no need subquery if want compute finish time row duration time same row.
Comments
Post a Comment