ระบุกฎการสรุปรวมสำหรับยอดรวมรายงาน

หัวข้อนี้อธิบายวิธีการระบุกฎการสรุปรวมสำหรับยอดรวมรายงานไว้อย่างชัดเจน ซึ่งช่วยปรับปรุงประสิทธิภาพ และมีจุดประสงค์เพื่อให้ผู้พัฒนาด้านเทคนิคเขียนรายงานต่างๆ ด้วย Oracle Analytics โดยเฉพาะ

ตัวเลขต่อไปนี้แสดงตัวอย่างที่การกำหนดรายงาน คือ ปี, เดือน และพื้นที่ของลูกค้า โดยมีเมตริค Count Distinct of Customers with Orders ซึ่งได้รับการกำหนดเป็นนับค่าเฉพาะของลูกค้าที่มีการสั่งซื้อ

คำอธิบาย GUID-4E9DB43C-F827-4BBB-A94D-5A91F3626C72-default.jpg มีดังนี้
.jpg

การสืบค้นแบบลอจิคัลมีลักษณะดังนี้

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

การสืบค้นแบบฟิสิคัลที่สร้างขึ้นมีลักษณะดังนี้

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

ค่าทั้งหมด 480 เป็นผลรวมของค่าส่วนประกอบ 182 + 113 + 185 เอ็กซ์เพรสชันการสืบค้นแบบลอจิคัลที่ใช้คำนวณยอดรวมคือ: “REPORT_AGGREGATE("A - Sample Sales"."Counts"."32 # of Cust with Orders (Cnt Distinct)" BY ) s_3”.

เมื่อใช้ REPORT_AGGREGATE ระบบจะคำนวณหายอดรวมโดยไม่อ้างอิงค่าส่วนประกอบ แต่สำหรับการออกแบบรายงานนี้ สามารถคำนวณยอดรวมที่ถูกต้องได้จากส่วนประกอบของรายงานนี้

หากคุณแก้ไขสูตรของคอลัมน์เพื่อเปลี่ยนแปลง Aggregation Rule (Totals Row) จาก Server Complex Aggregate เป็น Sum การสืบค้นแบบ SQL แบบลอจิคัลและฟิสิคัลจะมีการเปลี่ยนแปลง

ตัวเลขต่อไปนี้แสดงการสรุปรวมเดิม

คำอธิบาย GUID-96FB697B-24F7-41A9-8678-F99921E5BB19-default.png มีดังนี้
.png

ตัวเลขต่อไปนี้แสดงการสรุปรวมที่แก้ไข

คำอธิบาย GUID-ED289D12-C0BD-4588-B288-2069EAB3EB1D-default.png มีดังนี้
.png

การสืบค้น SQL แบบลอจิคัลที่แก้ไขมี REPORT_SUM แล้วในขณะนี้

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

นี่คือการสืบค้นแบบฟิสิคัลที่สร้างขึ้น

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

มีตัวเลือกที่เหมือนกันในการตั้งค่าการสรุปรวมอย่างแน่ชัดอยู่ในเวิร์กบุค โปรดดู จัดรูปแบบค่าตัวเลขของการแสดงข้อมูล สำหรับตัวอย่างนี้ สำหรับคอลัมน์ 'นับค่าเฉพาะของลูกค้าที่มีการสั่งซื้อ ให้เปลี่ยน วิธีสรุปรวม เป็น ผลรวม

ตรวจสอบรายงานของคุณเพื่อดูว่ามีการใช้กฎการสรุปรวมที่ดีที่สุดสำหรับรายงาน ใช้กฎการสรุปรวมที่แน่ชัดเมื่อการออกแบบรายงานอนุญาต

โปรดดูข้อมูลเพิ่มเติมเกี่ยวกับรายงานที่ สร้างการวิเคราะห์