New answers tagged

0

It is always a bad idea to save Dates Month as rtext mysql really has issues with that Your approach what very good, but i had a problem to get the right order with MonthAgg as ( select IFNULL(spendType,'Total') spendType , Sum(Case when spendMonth='January' then spendAmt else null end ) January , Sum(Case when spendMonth='February' then spendAmt else null ...


1

When you join your CTE with another table, SQL may (depending on the execution plan) execute the code within your CTE multiple time. Ex : Running this against the stackoverflow database: set statistics io on; with cte as ( select ID from Users where Location ='Canada' ) select top 100 title from Posts p join cte on cte.Id=p.ParentId select ID into #user ...


Top 50 recent answers are included