I'm new to SQL, and I'm not very good at more complex queries and functions.
So, I have this 1 table with sales:
id date seller_name buyer_name
---- ------------ ------------- ------------
1 2015-02-02 null Adrian
1 2013-05-02 null John B
1 2007-11-15 null Chris F
2 2014-07-12 null Jane A
2 2011-06-05 null Ted D
2 2010-08-22 null Maryanne A
3 2015-12-02 null Don P
3 2012-11-07 null Chris T
3 2011-10-02 null James O
I would like to update seller_namefor each id, putting buyer_namefrom the previous sale as seller_name on a newer sale date. For example, for id 1, John B will be seller at 2015-02-02and buyer at 2013-05-02. It makes sense?
PS This is an ideal case, the table is large, and the identifiers are not ordered so neatly.
source
share