title: The column '30' was specified multiple times for 'stat'
body: <p>i am facing this error on executing query
  The column '30' was specified multiple times for 'stat'.</p>
  
  <pre><code>FROM Probale
  --WHERE     (EntryDate BETWEEN @StartDate AND @Enddate)
  ORDER BY EntryDate
  
  DECLARE @cols NVARCHAR(4000)
  SELECT  @cols = COALESCE(@cols + ',[' + CONVERT(varchar, DATEPART(DAY, EntryDate), 112)
                  + ']','[' + CONVERT(varchar,DATEPART(DAY, EntryDate), 112) + ']')
  FROM    #Dates24
  ORDER BY EntryDate
  
  
  DECLARE  @qry NVARCHAR(4000) =
  N'SELECT * 
  FROM (SELECT ItemMasterFile.Descriptionitem,Probale.prdqty, 
  DATEPART(DAY, Probale.EntryDate)as DDate
  FROM Probale  Inner Join ItemMasterFile on Probale.Codeitem=ItemMasterFile.Codeitem )prd
  PIVOT (Sum(prdqty) FOR DDate IN (' + @cols + ')) AS stat 
  '
  -- Executing the query
  
  EXEC(@qry)```
  </code></pre>