求助,合并行,在网上没找到合适的办法
表如下:
number brushtime
A1306 2013-05-15 18:20:23.000
A1306 2013-05-15 18:20:24.000
A1212 2013-05-15 17:50:00.000
A1212 2013-05-16 08:00:03.000
A1306 2013-05-16 08:08:01.000
A1306 2013-05-16 12:10:02.000
A1212 2013-05-16 12:11:56.000
A1212 2013-05-16 12:35:23.000
A1306 2013-05-16 12:38:11.000
A1212 2013-05-16 17:20:26.000
A1306 2013-05-16 18:27:00.000
需要得到
工号 刷卡日期 刷卡1 刷卡2 刷卡3 刷卡4 刷卡5 刷卡6
A1306 2013/5/15 18:20:23 18:20:24 null null null null
A1212 2013/5/15 17:50:00 null null null null null
A1306 2013/5/16 08:08:01 12:10:02 12:38:11 18:27:00 null null
A1212 2013/5/16 08:00:03 12:11:56 12:35:23 17:20:26 null null
------解决方案--------------------分组编号,
row_number() over(partition by number,convert(date,brushtime,23) order by brushtime)
然后
max(case when 编号=1 then brushtime else null end),
max(case when 编号=2 then brushtime else null end),
...
一直到6不就行