I am writing a query like this
select b.head_code,
sum(a.pla_basic ) as up_basic,sum(A. PLA_EDUCESS) as
up_EDUCESS,sum( A.PLA_ADDLGSI) as up_ADDLGSI,sum( A.PLA_ADDLTT)
as up_ADDLDUTYTAND T, SUM(A.PLA_OTHER S) AS up_SAED,sum(A.P LA_CESS) as
up_CESS, sum(A.PLA_SED) as up_SED,sum(A.PL A_NCCD)
as up_NCCD from data_table as a inner join ceth_master b on
a.ceth_id=b.cet h_id inner join ECC_MASTER as C
on A.ECC_CODE=C.EC C_CODE where
b.head_code in (select b.head_code from data_table as a left outer join
ceth_master as b on a.ceth_id=b.cet h_id where a.ceth_no between b.start_ceth
and b.end_ceth and a.month_id=7 and a.financial_yea r_id=5)
group by b.head_code
Here suppose two head_code are same then I am calculating their data.
Upto this it is fine.
Now I want to add some more columns in my query so I write like this.
select b.head_code,B.D ESCR1,C.ECC_NAM E,A.MONTH_ID,A. FINANCIAL_YEAR_ ID,b.start_ceth ,
sum(a.pla_basic ) as up_basic,sum(A. PLA_EDUCESS) as up_EDUCESS,sum( A.PLA_ADDLGSI) as up_ADDLGSI,sum( A.PLA_ADDLTT)
as up_ADDLDUTYTAND T, SUM(A.PLA_OTHER S) AS up_SAED,sum(A.P LA_CESS) as up_CESS, sum(A.PLA_SED) as up_SED,sum(A.PL A_NCCD)
as up_NCCD,'first' as Type from data_table as a inner join ceth_master b on a.ceth_id=b.cet h_id inner join ECC_MASTER as C
on A.ECC_CODE=C.EC C_CODE where
b.head_code in (select b.head_code from data_table as a left outer join
ceth_master as b on a.ceth_id=b.cet h_id where a.ceth_no between b.start_ceth and b.end_ceth
AND A.DELETE_STATUS ='N' and a.month_id = 7 and a.financial_yea r_id = 5 AND A.ECC_CODE = 130801)
group by b.head_code,b.d escr1,c.ecc_nam e,A.MONTH_ID,A. FINANCIAL_YEAR_ ID,b.start_ceth
but this time I am not getting the result as expected.The Head_code is repeating.
Any help is appreciated.
It's urgent .
Thank u.
select b.head_code,
sum(a.pla_basic ) as up_basic,sum(A. PLA_EDUCESS) as
up_EDUCESS,sum( A.PLA_ADDLGSI) as up_ADDLGSI,sum( A.PLA_ADDLTT)
as up_ADDLDUTYTAND T, SUM(A.PLA_OTHER S) AS up_SAED,sum(A.P LA_CESS) as
up_CESS, sum(A.PLA_SED) as up_SED,sum(A.PL A_NCCD)
as up_NCCD from data_table as a inner join ceth_master b on
a.ceth_id=b.cet h_id inner join ECC_MASTER as C
on A.ECC_CODE=C.EC C_CODE where
b.head_code in (select b.head_code from data_table as a left outer join
ceth_master as b on a.ceth_id=b.cet h_id where a.ceth_no between b.start_ceth
and b.end_ceth and a.month_id=7 and a.financial_yea r_id=5)
group by b.head_code
Here suppose two head_code are same then I am calculating their data.
Upto this it is fine.
Now I want to add some more columns in my query so I write like this.
select b.head_code,B.D ESCR1,C.ECC_NAM E,A.MONTH_ID,A. FINANCIAL_YEAR_ ID,b.start_ceth ,
sum(a.pla_basic ) as up_basic,sum(A. PLA_EDUCESS) as up_EDUCESS,sum( A.PLA_ADDLGSI) as up_ADDLGSI,sum( A.PLA_ADDLTT)
as up_ADDLDUTYTAND T, SUM(A.PLA_OTHER S) AS up_SAED,sum(A.P LA_CESS) as up_CESS, sum(A.PLA_SED) as up_SED,sum(A.PL A_NCCD)
as up_NCCD,'first' as Type from data_table as a inner join ceth_master b on a.ceth_id=b.cet h_id inner join ECC_MASTER as C
on A.ECC_CODE=C.EC C_CODE where
b.head_code in (select b.head_code from data_table as a left outer join
ceth_master as b on a.ceth_id=b.cet h_id where a.ceth_no between b.start_ceth and b.end_ceth
AND A.DELETE_STATUS ='N' and a.month_id = 7 and a.financial_yea r_id = 5 AND A.ECC_CODE = 130801)
group by b.head_code,b.d escr1,c.ecc_nam e,A.MONTH_ID,A. FINANCIAL_YEAR_ ID,b.start_ceth
but this time I am not getting the result as expected.The Head_code is repeating.
Any help is appreciated.
It's urgent .
Thank u.
Comment