当前位置: 代码迷 >> Sql Server >> 跪求高手解答,非常着急该如何处理
  详细解决方案

跪求高手解答,非常着急该如何处理

热度:44   发布时间:2016-04-27 18:01:38.0
跪求高手解答,非常着急!!!!!!
id prev_Id seat_no seat_type mark sellwind
196 888 1 15 1 20
197 999 2 15 1 20

上面除seat_no列外分成两行,其他列合并成一行,第二行只显示seat_no为2,第二行其他列为空

------解决方案--------------------
id,也能相加?
------解决方案--------------------
SQL code
create table t3 (id int, prev_Id int, seat_no int, seat_type int, mark int, sellwind int)insert into t3select 196, 888, 1, 15, 1, 20 union allselect 197, 999, 2, 15, 1, 20select * from t3id          prev_Id     seat_no     seat_type   mark        sellwind----------- ----------- ----------- ----------- ----------- -----------196         888         1           15          1           20197         999         2           15          1           20select (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) sellwindfrom t3 aleft join t3 b on a.seat_no=b.seat_no-1id          prev_Id     seat_no     seat_type   mark        sellwind----------- ----------- ----------- ----------- ----------- -----------393         1887        1           30          2           40NULL        NULL        2           NULL        NULL        NULL
  相关解决方案