select org, leaseform, sum(fesitmatecapital)
from (
select a.fesitmatecapital, b.fname_l2 org, c.fname_l2 leaseform
from t_afl_con_contract a
inner join t_org_baseunit b on a.fbusinessorgid = b.fid
inner join t_afl_bd_leaseform c on a.fleaseformid = c.fid)
group by rollup(org, leaseform)
order by org;
--------------------------------
select org, leaseform, sum(fesitmatecapital)
from (
select a.fesitmatecapital, b.fname_l2 org, c.fname_l2 leaseform
from t_afl_con_contract a
inner join t_org_baseunit b on a.fbusinessorgid = b.fid
inner join t_afl_bd_leaseform c on a.fleaseformid = c.fid)
group by cube(org, leaseform)
order by org;
-------------------
select org, leaseform, sum(fesitmatecapital),grouping(org),grouping(leaseform)
from (
select a.fesitmatecapital, b.fname_l2 org, c.fname_l2 leaseform
from t_afl_con_contract a
inner join t_org_baseunit b on a.fbusinessorgid = b.fid
inner join t_afl_bd_leaseform c on a.fleaseformid = c.fid)
group by cube(org, leaseform)
order by org;
-----------------------------
select org, leaseform, sum(fesitmatecapital)
from (
select a.fesitmatecapital, b.fname_l2 org, c.fname_l2 leaseform
from t_afl_con_contract a
inner join t_org_baseunit b on a.fbusinessorgid = b.fid
inner join t_afl_bd_leaseform c on a.fleaseformid = c.fid)
group by grouping sets(org, leaseform)
order by org;
from (
select a.fesitmatecapital, b.fname_l2 org, c.fname_l2 leaseform
from t_afl_con_contract a
inner join t_org_baseunit b on a.fbusinessorgid = b.fid
inner join t_afl_bd_leaseform c on a.fleaseformid = c.fid)
group by rollup(org, leaseform)
order by org;
--------------------------------
select org, leaseform, sum(fesitmatecapital)
from (
select a.fesitmatecapital, b.fname_l2 org, c.fname_l2 leaseform
from t_afl_con_contract a
inner join t_org_baseunit b on a.fbusinessorgid = b.fid
inner join t_afl_bd_leaseform c on a.fleaseformid = c.fid)
group by cube(org, leaseform)
order by org;
-------------------
select org, leaseform, sum(fesitmatecapital),grouping(org),grouping(leaseform)
from (
select a.fesitmatecapital, b.fname_l2 org, c.fname_l2 leaseform
from t_afl_con_contract a
inner join t_org_baseunit b on a.fbusinessorgid = b.fid
inner join t_afl_bd_leaseform c on a.fleaseformid = c.fid)
group by cube(org, leaseform)
order by org;
-----------------------------
select org, leaseform, sum(fesitmatecapital)
from (
select a.fesitmatecapital, b.fname_l2 org, c.fname_l2 leaseform
from t_afl_con_contract a
inner join t_org_baseunit b on a.fbusinessorgid = b.fid
inner join t_afl_bd_leaseform c on a.fleaseformid = c.fid)
group by grouping sets(org, leaseform)
order by org;