Hi,Need help in Pivot function. I have a table with following rows.[code="plain"][b]FY REVCODE Jul Jun [/b]2015 BNQ 1054839 20000002015 FNB 89032 10000002015 RS 1067299 3000000[/code]I am looking to convert it to[code="plain"][b]Month BNQ FNB RS[/b]JUL 1054839 89032 1067299 JUN 2000000 1000000 3000000[/code]I tried with the following and result is coming for one month i.e. JUL but not with the second Month i.e Jun[code="sql"]SELECT 'Jul1' AS MON, [BNQ], [FNB], [RS]FROM(SELECT REVENUECODE, SUM(ROUND(((Jul/31)*30),0)) AS JUL FROM RM_USERBUDGETTBL WHERE USERNAME='rahul' AND FY=2015 GROUP BY REVENUECODE, USERNAME ) AS SourceTablePIVOT(SUM(JUL) FOR REVENUECODE IN ([BNQ], [FNB], [RS])) AS PivotTable[/code]Results:[code="plain"][b]MONTH BNQ FNB RS[/b]Jul1 1054839 89032 1067299[/code]Thanks in advance..-Rahuul
↧