Dit onderwerp beschrijft manieren om de aggregatieregel voor rapporttotalen expliciet toe te wijzen, waarmee de prestaties worden verbeterd, en is specifiek bedoeld voor technische ontwikkelaars die rapporten met Oracle Analytics schrijven.
In de volgende afbeelding wordt een voorbeeld getoond waarbij de rapportdefinitie jaar, maand en klantenregio is, met een metric 'Aantal verschillende waarden van klanten met orders'
die wordt gedefinieerd als een aantal verschillende waarden van klanten met orders.
De logische query ziet er als volgt uit:
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
De fysieke query die is gegenereerd, ziet er als volgt uit:
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
De totale waarde van 480 is de som van de klantwaarden: 182 + 113 + 185. De logische queryuitdrukking die het totaal berekent is : “REPORT_AGGREGATE("A - Sample Sales"."Counts"."32 # of Cust with Orders (Cnt Distinct)" BY ) s_3”.
Wanneer REPORT_AGGREGATE
wordt gebruikt, wordt het totaal onafhankelijk van de klantwaarden berekend. Maar voor dit rapportontwerp kan het juiste aantal worden berekend met de klanten voor dit rapport.
Als u de kolomformule bewerkt om de 'Aggregatieregel (rij 'Totalen')' te wijzigen van 'Complexe aggregatie server' in 'Som', wordt de logische en fysieke SQL-query gewijzigd.
In de onderstaande afbeelding wordt de oorspronkelijke aggregatie getoond.
In de onderstaande afbeelding wordt de bewerkte aggregatie getoond.
De bewerkte logische SQL-query heeft nu 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
Dit is de fysieke query die is gegenereerd:
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
Dezelfde optie om de aggregatie expliciet in te stellen is beschikbaar in werkmappen. Zie voor meer informatie: Numerieke waarden van visualisaties opmaken. In dit voorbeeld wijzigt u voor de kolom 'Aantal verschillende klanten met orders' 'Aggregatiemethode' in 'Som'.
Evalueer uw rapporten om te controleren of de beste aggregatieregel voor het rapport wordt gebruikt. Gebruik een expliciete aggregatieregel wanneer het ontwerp van het rapport dat toestaat.
Zie voor meer informatie:Analyses maken