Tag Info

New answers tagged


So at this point in the code: isnull((processeddate),' ') as 'Null' The column processeddate is not visible to SQL Server, because you are selecting available fields from the result of the following query: SELECT EmpID, EmpDeductAmt, month(ProcessedDate) as TMonth FROM [dbo].[Invoices] where Inv_Number not in ('1035','1039') ...along with the pivoted ...


You can use PIVOT with dynamic sql to solve your problem. Below is a simple implementation to solve the issue. The query will support any number of months you may have. Make sure the length of @pivcols is large enough to accommodate the maximum anticipated string length for all the current and future months (povot columns) concatenated. --Table structure-- ...

Top 50 recent answers are included