Create a Table:
----------------------------------------------
TABLE [dbo].[Salary](
[SalaryId] [int] IDENTITY(1,1) NOT NULL,
[EmpId] [varchar](50) NULL,
[SalaryMonth] [date] NULL,
[SalaryAmt] [decimal](18, 0) NULL,
//========================PIVOT Query=================================
Select pv.* From
(
Select * From (
Select EmpId,Month(SalaryMonth)Months,SalaryAmt From Salary
) sal
PIVOT (SUM(SalaryAmt)for Months in([1],[2],[3]) )As p
)pv
----------------------------------------------
TABLE [dbo].[Salary](
[SalaryId] [int] IDENTITY(1,1) NOT NULL,
[EmpId] [varchar](50) NULL,
[SalaryMonth] [date] NULL,
[SalaryAmt] [decimal](18, 0) NULL,
//========================PIVOT Query=================================
Select pv.* From
(
Select * From (
Select EmpId,Month(SalaryMonth)Months,SalaryAmt From Salary
) sal
PIVOT (SUM(SalaryAmt)for Months in([1],[2],[3]) )As p
)pv
0 Comments