Click here to Skip to main content
15,892,965 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I Have  a Table Like this,
---------------
| Loc | Month/Year | Cnt | Per |
| A | Jan-16 | 123 | 10.05 |  
| A | Feb-16 | 356 | 15.67 |  
| B | Jan-16 | 123 | 12.30 |  
| B | Feb-16 | 101 | 10.59 |  
| C | Jan-16 | 582 | 56.30 |  
| C | Feb-16 | 945 | 90.59 |    


----------

And i need output like this,
----------
| Loc | Jan-16(Cnt) | Jan-16(per) | Feb-16(Cnt) | Feb-16(per) |
| A | 123 | 10% | 356 | 16% |  
| B | 123 | 12% | 101 | 11% |  
| C | 582 | 56% | 945 | 91% |  

----------

I'm adding the query that i tried hope this doesn't work.

Can anyone help me on this query please.
NOTE: Numbers mentioned are may not be correct.

Thanks in Advance.


What I have tried:

select * from (
	 SELECT [Loc],[Month/Year] ,[Cnt],[Per]
	 FROM Temp ) src
	 PIVOT(
			SUM(Cnt)
			FOR [Month/Year] IN ([Aug-2016],[Dec-2016],[Jul-2016],[Jun-2016],[Nov-2016],[Oct-2016],[Sep-2016])
		) AS PVT_Table
Posted
Updated 13-Jan-17 9:10am
Comments
F-ES Sitecore 13-Jan-17 8:41am    
This is your third thread on this issue, rather than creating new threads update your existing one with any new info as it stops people wasting their time giving solutions that have already been given.

 
Share this answer
 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900