What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI
SELECT v.rep, Sum(v.[Gross Rev]) as GrossRev, DATENAME(month, v.Funded) as Mth , month(v.Funded) as MthI Into #temp FROM CRMPROD_01.dbo.v_P_Reporting v WHERE v.Funded is not null and v.Status <> 'Closed' and (YEAR(v.Funded) = YEAR(getdate())) and (MONTH(v.Funded) > MONTH(getdate())-@) Group by rep, v.Funded ORDER BY v.rep, month(v.Funded) --Create Dynamic SQl and Pivot declare @sql varchar(4000) declare @columns varchar(8000) select @columns = coalesce(@columns+',','') + '[' + Mth + ']' from #temp group by Mth, MthI order by MthI set @sql = ' SELECT [rep], ' + @columns + ' FROM (SELECT [rep], [GrossRev], [Mth] as Mth from #temp) src PIVOT (Sum ([GrossRev]) FOR Mth IN (' + @columns + ') ) AS pvt' EXEC (@sql) Drop table #temp
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.