|
|
Re: Data is set has Column name during Union Query [message #402178 is a reply to message #402030] |
Fri, 08 May 2009 00:15 |
|
hi michel,
The query i am using is follows.
select a.CODE,a.emplname,a.MTH,a.YRS,
sum(case when salcode = 'E001' then amount End) "GROSS" ,
sum(case when salcode = 'D002' then amount End) "PF",
sum(case when salcode = 'E002' then amount End) "NETPAY"
From
(
(
select a.empcode"CODE",b.empname,monthno"MTH",yearno "YRS",c.saldesc, c.salcode,
Amount from salaryfile a,employmast b,salarydetails c
where a.empcode = b.empcode
and a.salcode = c.salcode
and a.salcode in ('D002') and
a.empcode ='2000742'
and a.monthno <= 03
and a.yearno =2009
)
Union
(
select a.empcode"CODE",b.empname,monthno"MTH",yearno "YRS",c.saldesc, c.salcode,
amount from salaryfile a,employmast b,salarydetails c
where a.empcode = b.empcode
and a.salcode = c.salcode
and a.salcode in ('E001','E002')
and a.empcode ='2000742'
and a.monthno <= 03
and a.yearno =2009
)
) a
Group by a.CODE,a.emplname,a.MTH,a.YRS
order by a.yrs,a.mth;
In this query split the amount of salary for the employee by Salcode. Here i used the saldesc is the field i required to display as a heading for the amount column during the splitup.
Thanks and Regards,
C V S
|
|
|
|