Bu konu rapor toplamları için toplama kuralını açıkça atamanın yollarını açıklar ve bu da performansı artırmaya yardımcı olur ve özellikle Oracle Analitik ile rapor yazan teknik geliştiriciler için oluşturulmuştur.
Aşağıdaki şekil, rapor tanımının yıl, ay ve müşteri bölgesi olduğu ve Count Distinct of Customers with Orders
metriğinin, siparişleri olan müşterilerin farklı sayısı olarak tanımlandığı bir örneği gösterir.
Mantıksal sorgu şu şekilde görünür:
SELECT 0 s_0, "A - Sample Sales"."Cust Regions"."C50 Region" s_1, "A - Sample Sales"."Counts"."32 # of Cust with Orders (Cnt Distinct)" s_2, REPORT_AGGREGATE("A - Sample Sales"."Counts"."32 # of Cust with Orders (Cnt Distinct)" BY ) s_3 FROM "A - Sample Sales" WHERE ("Time"."T02 Per Name Month" = '2011 / 11') ORDER BY 2 ASC NULLS LAST FETCH FIRST 500001 ROWS ONLY
Oluşturulan fiziksel sorgu şu şekilde görünür:
WITH SAWITH0 AS (select count(distinct T42433.Cust_Key) as c1, T42430.Region as c2 from BISAMPLE.SAMP_CUSTOMERS_D T42428 /* D60 Customers */ , BISAMPLE.SAMP_ADDRESSES_D T42430 /* D62 Customers Addresses */ , BISAMPLE.SAMP_TIME_MTH_D T42405 /* D02 Time Month Grain */ , BISAMPLE.SAMP_REVENUE_F T42433 /* F10 Billed Rev */ where ( T42405.Mth_Key = T42433.Bill_Mth_Key and T42405.Per_Name_Month = '2011 / 11' and T42428.Cust_Key = T42433.Cust_Key and T42428.Address_Key = T42430.Address_Key ) group by T42430.Region), SAWITH1 AS (select count(distinct T42433.Cust_Key) as c1 from BISAMPLE.SAMP_TIME_MTH_D T42405 /* D02 Time Month Grain */ , BISAMPLE.SAMP_REVENUE_F T42433 /* F10 Billed Rev */ where ( T42405.Per_Name_Month = '2011 / 11' and T42405.Mth_Key = T42433.Bill_Mth_Key ) ) select D1.c1 as c1, D1.c2 as c2, D1.c3 as c3, D1.c4 as c4 from ( select D1.c1 as c1, D1.c2 as c2, D1.c3 as c3, D1.c4 as c4 from (select 0 as c1, D1.c2 as c2, D1.c1 as c3, D2.c1 as c4, ROW_NUMBER() OVER (PARTITION BY D1.c2 ORDER BY D1.c2 ASC) as c5 from SAWITH0 D1, SAWITH1 D2 ) D1 where ( D1.c5 = 1 ) order by c2 ) D1 where rownum <= 500001
Toplam değer (480), bileşen değerlerin (182 + 113 + 185) toplamıdır. Toplamı hesaplayan mantıksal sorgu ifadesi: “REPORT_AGGREGATE("A - Sample Sales"."Counts"."32 # of Cust with Orders (Cnt Distinct)" BY ) s_3”.
REPORT_AGGREGATE
kullanıldığında toplam bileşen, değerlerden bağımsız olarak hesaplanır. Ancak bu rapor tasarımında, bu raporun bileşenlerinden doğru toplam hesaplanabilir.
Aggregation Rule (Totals Row) değerini Server Complex Aggregate iken Sum olarak değiştirmek için sütun formülünü düzenlerseniz mantıksal ve fiziksel SQL sorgusu değişir.
Aşağıdaki şekil esas toplamayı gösterir.
Aşağıdaki şekil değiştirilen toplamayı gösterir.
Değiştirilen mantıksal SQL artık REPORT_SUM
içerir.
SELECT 0 s_0, "A - Sample Sales"."Cust Regions"."C50 Region" s_1,"A - Sample Sales"."Counts"."32 # of Cust with Orders (Cnt Distinct)" s_2, REPORT_SUM("A - Sample Sales"."Counts"."32 # of Cust with Orders (Cnt Distinct)" BY ) s_3 FROM "A - Sample Sales" WHERE ("Time"."T02 Per Name Month" = '2011 / 11') ORDER BY 2 ASC NULLS LAST FETCH FIRST 500001 ROWS ONLY
Oluşturulan fiziksel sorgu şudur:
WITH SAWITH0 AS (select count(distinct T42433.Cust_Key) as c1, T42430.Region as c2 from BISAMPLE.SAMP_CUSTOMERS_D T42428 /* D60 Customers */ , BISAMPLE.SAMP_ADDRESSES_D T42430 /* D62 Customers Addresses */ , BISAMPLE.SAMP_TIME_MTH_D T42405 /* D02 Time Month Grain */ , BISAMPLE.SAMP_REVENUE_F T42433 /* F10 Billed Rev */ where ( T42405.Mth_Key = T42433.Bill_Mth_Key and T42405.Per_Name_Month = '2011 / 11' and T42428.Cust_Key = T42433.Cust_Key and T42428.Address_Key = T42430.Address_Key ) group by T42430.Region), SAWITH1 AS (select 0 as c1, D1.c2 as c2, D1.c1 as c3 from SAWITH0 D1) select D1.c1 as c1, D1.c2 as c2, D1.c3 as c3, D1.c4 as c4 from ( select D1.c1 as c1, D1.c2 as c2, D1.c3 as c3, sum(D1.c3) over () as c4 from SAWITH1 D1 order by c2 ) D1 where rownum <= 500001
Toplamayı açıkça ayarlamaya yönelik aynı seçenek çalışma kitaplarında da mevcuttur. Bkz. Görselleştirmelerin Sayısal Değerlerini Formatlama. Bu örnek için, Siparişleri Olan Farklı Müşterileri Say sütununa ilişkin olarak, Birleştirme Yöntemi'ni Toplam olarak değiştirin.
Rapor için en iyi toplama kuralının kullanıldığını görmek için raporlarınızı gözden geçirin. Rapor tasarımı izin verdiğinde belirtilmiş bir toplama kuralı kullanın.
Raporlar hakkında daha fazla bilgi için bkz. Analiz Oluşturma.