hello friends ,
i want to display data like this for employee salary.
if i search data between nov2012 to feb 2013
name nov2012 dec2012 jan2013
pawan 31110 22020 2000
pawan 31110 22020 2000
pawan 31110 22020 2000
pawan 31110 22020 2000
this is my query
Select id,name,fathername,cdepartment, [Jan],[Feb],[Mar],[Apr],[May],[Jun],[Jul],[Aug],[Sep],[Oct],[Nov],[Dec]
From
(
Select e.cemployeecode as id,e.cfirstname+space(1)+e.clastname as name,e.cfatherfirstname+space(1)+e.cfatherlastname as fathername,
CAST(DateName(MONTH,cast(cast (i.lmonthid as varchar(200))+'/01/'+cast(i.lyearid as varchar(200)) as datetime)) as varchar(3))
as Mon, round(i.HWF,2) as HWF,ed.cdepartment
From invoice i inner join employee e on e.cemployeecode=i.cemployeeid
inner join employeedepartment ed on ed.ldepartmentid=e.ldepartmentid
where i.lyearid=@yearid and i.lcompanyid =@companyid
) as SourceTable
PIVOT
(
Sum(HWF)
For Mon in ( [Jan],[Feb],[Mar],[Apr],[May],[Jun],[Jul],[Aug],[Sep],[Oct],[Nov],[Dec] )
) as PivotTable
Plz help me rectifying it according to my requirement.