var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Sql to update table with last day rank
I have a table with device, date, website and rank, previous_rank as columns e.g.
device date website rank previous_rank
1 20110812 www.xyz.com 1 -
1 20110812 www.abc.com 1 -
Now, I want to update this table setting previous day rank in previous_rank column(after we get next days data). But I am not able to get it in one sql shot, please help me with this.
I am able to write a select query which should select last day rank, but can't figure out how to update it
select t1.device, t1.website t2.rank from
web_by_rank t1, web_by_rank t2 where
t1.date_key = 20110809 and
t2.date_key = 20110808 and
t2.website = t1.website and
t2.device = t1.device
Last edited by abhigyan.agrawal; 08-12-11 at 01:58.
Check the LAG analytic function which provides access to a row at a given physical offset prior to that position.
Tags for this Thread