When you use pivot statement, the name of column have " ' " in the beginning and ending of name, such as 'Jan', 'Feb'.... I was using summ.* to all columns and it was causing the error. When I changed the name ignoring " ' ", it worked.