siva nathan

siva nathan

  • 942
  • 828
  • 231.2k

how to select Empty column in pivot for display row_no

Apr 11 2017 7:04 AM
how to select Empty column in pivot
im using pivot in my sql server to display rows as columns in a report,i want to select empty column in my sql pivot 
 
 empid name 2
 1 a X X L
 2 b X CL X
it is possible to select like this
my expected answer is to select row no in sql pivot column
add a new column for s.no 
 
SET @query='SELECT Empid,EmployeeName,Department,'+@cols+' from
(select Empid,EmployeeName,department,day(Attdate)[dtDay],present from temp1 ) x
pivot
(
Max(present)
for dtDay in ('+@cols+'
)) p'
EXECUTE (@query);
i cant add a new column in my pivot table
 
 s.no empid name 2 Totaldays
 1 1 a X X 2
 2 2 b X CL 1
 

Answers (1)