how to convert this table in mysql
month | Number_oF_User
1 | 3
2 | 13
3 | 2
12 | 3
convert in to
month 1 2 3 12
number_of_user 3 13 2 3
how to convert this table in mysql
month | Number_oF_User
1 | 3
2 | 13
3 | 2
12 | 3
convert in to
month 1 2 3 12
number_of_user 3 13 2 3
You Have to Use Your Query Something Like this:
Select * From ( Select 'number_of_user' as Itm, [1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12] From ( Select Month(Your Column) as Mon, Your Number_of_User Column From Your Table Name T1 --where Your Conditions
) as SourceTable
Pivot
(
Your Number_of_User Column
For Mon in ([1],[2],[3],[4],[5],[6],[7],[8],[9],[10],[11],[12])
) as Your TableName t1
) A -- This Will Be Applied If You Want sum of Each Row Horizontally Cross Apply (Select SUM(Camount) as SumVal, AVG(Camount) as AvgVal From paymentreciept i Where i.PaymentType = a.Itm) b