首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

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

2012-01-19 
跪求高手解答,非常着急!!!!!!idprev_Idseat_noseat_typemarksellwind196888115120197999215120上面除seat_

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

热点排行