读书人

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

发布时间: 2012-01-19 20:57:58 作者: rapoo

跪求高手解答,非常着急!!!!!!
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 

读书人网 >SQL Server

热点推荐