如何在两个枢轴柱之间设置空间

时间:2019-02-01 05:36:10

标签: sql sql-server-2012 pivot

查询枢轴带有两个单词,列中有空格

DECLARE @cols NVARCHAR(MAX) SELECT

   top 24 @cols = COALESCE(@cols + ',[' + CONVERT(varchar, DateIn ,21 )                 + ']','[' + CONVERT(varchar, DateIn ,21) + ']'  )

      FROM    DailyAttendanceMaster  where   DateIn between '2018-10-01  00:00:00.000' and '2018-10-24 00:00:00.000'  
        DECLARE @qry NVARCHAR(4000) SET
         @qry = 'SELECT * FROM (SELECT Employee_Master.Employee_Name, convert(char(5), TimeIn, 108)+    + convert(char(5), TimeOutD, 108)TimeIn  , DailyAttendanceMaster.DateIn FROM DailyAttendanceMaster inner join Employee_Master on Employee_Master.essl_EmpID=DailyAttendanceMaster.EMPID)emp
          PIVOT (MAX(TimeIn) FOR DateIn IN (' + @cols + ')) AS stat'  
          EXEC(@qry) 

这是我的数据透视查询,我将两列连接在一起,即TimeIn和TimeOutD,它可以正常工作,但是我想在两列之间留出空间,这样我该怎么做

enter image description here

0 个答案:

没有答案