日期:2014-05-18 浏览次数:20457 次
create table t3 (id int, prev_Id int, seat_no int, seat_type int, mark int, sellwind int) insert into t3 select 196, 888, 1, 15, 1, 20 union all select 197, 999, 2, 15, 1, 20 select * from t3 id prev_Id seat_no seat_type mark sellwind ----------- ----------- ----------- ----------- ----------- ----------- 196 888 1 15 1 20 197 999 2 15 1 20 select (a.id+b.id) id, (a.prev_Id+b.prev_Id) prev_Id, a.seat_no, (a.seat_type+b.seat_type) seat_type, (a.mark+b.mark) mark, (a.sellwind+b.sellwind) sellwind from t3 a left join t3 b on a.seat_no=b.seat_no-1 id prev_Id seat_no seat_type mark sellwind ----------- ----------- ----------- ----------- ----------- ----------- 393 1887 1 30 2 40 NULL NULL 2 NULL NULL NULL