hi ,
very goood morning to all
i have a table like below, which is contain area, zone, branch wise value
in that i want to get company total as a column and area total as a another column and zone total in next column
AREA ZONE BRANCH VALUE TN CENTRAL AMB 100 TN CENTRAL TNF 100 TN CENTRAL SDGD 100 TN CENTRAL ERW 100 TN NORTH AMB 50 TN SOUTH AMB 50 TN WEST AMB 60 AP AAA AMB 120 AP BBB AMB 140 AP CCC AMB 180 AP DDD AMB 200
my expected output is like below
AREA ZONE BRANCH VAL comtot areatot zonetot TN CENTRAL AMB 100 1200 560 400 TN CENTRAL TNF 100 1200 560 400 TN CENTRAL SDGD 100 1200 560 400 TN CENTRAL ERW 100 1200 560 400 TN NORTH AMB 50 1200 560 50 TN SOUTH AMB 50 1200 560 50 TN WEST AMB 60 1200 560 60 AP AAA AMB 120 1200 640 120 AP BBB AMB 140 1200 640 140 AP CCC AMB 180 1200 640 180 AP DDD AMB 200 1200 640 200
i acheived this by using query but its will affect performance because my real time scenario dealing with laks of records
select a.*,b.company_tot,c.area_tot,d.zone_tot from FESIBILITY_CHECK a cross join (select SUM(value)company_tot from FESIBILITY_CHECK )b join (select SUM(value)area_tot,area from FESIBILITY_CHECK group by area)c on a.AREA = c.area join (select SUM(value)zone_tot,area,zone from FESIBILITY_CHECK group by area,zone)d on a.AREA=d.area and a.ZONE = d.ZONE
so i planned to use cube and roll up but i don't get desired result
thanks in advance,
give a quick response as soon as possible.