SQL Server数据库合并表格数据是利用ROW_NUMBER来实现的.
主要的SQL语句如下:
select A.Date,A.MID,A.Contents1,B.Contents2,B.Passed from
(select ROW_NUMBER() over(partition by Date order by Date) as MID,Date,Contents as Contents1 from History where Type=0 ) A
left join
(select ROW_NUMBER() over(partition by Date order by Date) as MID,Date,Contents as Contents2,Passed from History where Type=1 ) B
on A.Date=B.Date and A.MID=B.MID
union
selectB.Date,B.MID, A.Contents1,B.Contents2,B.Passed from
(select ROW_NUMBER() over(partition by Date order by Date) as MID,Date,Contents as Contents1 from History where Type=0 ) A
right join
(select ROW_NUMBER() over(partition by Date order by Date) as MID,Date,Contents as Contents2,Passed from History where Type=1) B
on A.Date=B.Date and A.MID=B.MID
logo设计
创造品牌价值
¥500元起
APP开发
量身定制,源码交付
¥2000元起
商标注册
一个好品牌从商标开始
¥1480元起
公司注册
注册公司全程代办
¥0元起
查
看
更
多