i got so many examples for pivot but i need both pivot and concatenate like below. i am very new to sql. Please guide me,i need dynamic pivot in both country names and years.
my table like
Country | year | played | win | loss
----------------------------------------
India | 2005 | 40 | 15 | 25
India | 2006 | 29 | 10 | 19
India | 2007 | 52 | 32 | 20
China | 2005 | 100 | 68 | 32
China | 2006 | 90 | 60 | 30
China | 2007 | 110 | 70 | 40
Now i need the result table like
Country | Stat | 2005 | 2006 |2007
-----------------------------------
India | played | 40 | 29 | 52
| win | 15 | 10 | 30
| loss | 25 | 19 | 22
China | played | 100 | 90 | 110
| win | 68 | 60 | 70
| loss | 32 | 30 | 40