|
本帖最后由 mssql_wangwang 于 2016-11-15 15:40 编辑
select 车牌号,派团编号,
max(case when [2016-02-11] is not null then (派团编号) else '' end )[2016-02-11],
max(case when [2016-02-12] is not null then (派团编号) else '' end ) [2016-02-12],
max(case when [2016-02-13] is not null then (派团编号) else '' end ) [2016-02-13],
max(case when [2016-02-14] is not null then (派团编号) else '' end ) [2016-02-14],
max(case when [2016-02-15] is not null then (派团编号) else '' end ) [2016-02-15],
max(case when [2016-02-16] is not null then (派团编号) else '' end ) [2016-02-16],
max(case when [2016-02-17] is not null then (派团编号) else '' end ) [2016-02-17],
max(case when [2016-02-18] is not null then (派团编号) else '' end ) [2016-02-18],
max(case when [2016-02-19] is not null then (派团编号) else '' end ) [2016-02-19],
max(case when [2016-02-20] is not null then (派团编号) else '' end ) [2016-02-20] from [行程表L]
pivot (max(时间)
for 时间 in([2016-02-11],
[2016-02-12],
[2016-02-13],
[2016-02-14],
[2016-02-15],
[2016-02-16],
[2016-02-17],
[2016-02-18],
[2016-02-19],
[2016-02-20]))
a
group by 车牌号,派团编号
order by 车牌号 desc
|
|