合并单个员工的多个值

时间:2015-08-21 04:57:19

标签: sql-server

我有一张表格如下:

empId appid rolename contextname contextvalue  fromdate      todate
'1234' 1     admin    manage       view        2015-01-08    2015-31-08
'1234' 1     admin    company      US          2015-01-08    2015-31-08
'5678' 2     auditor  action       audit       2015-01-08    2015-15-08
'5678' 2     auditor  report       view        2015-01-08    2015-10-08

我给出了显示结果如下

empid  appid  rolename   context1       context2   fromdate       todate
'1234'  1      admin    manage:View    company:US  2015-01-08    2015-31-08
'5678'  2      auditor  action:Audit     NA        2015-01-08    2015-15-08
'5678'  2      auditor    NA           report:view 2015-01-08    2015-10-08

我已经尝试了stuffcoalesce功能,但我拥有的数据很大(10000条记录)。
请帮助..

0 个答案:

没有答案