SlideShare a Scribd company logo
1 of 32
Download to read offline
Oracle APEX & Oracle Analytic Views
Ing. Roberto Capancioni
31st March 2023
Chi Sono
Ing. Roberto Capancioni
–Sviluppo Oracle APEX
–Board Member ITOUG
Email: sviluppo@capancioni.com
Linkedin: https://www.linkedin.com/in/robertocapancioni
Web: https://capancioni.com
3
The Data
Date
Customer
Product
Sales
E/R Diagram
Query
Group by
Amount and quantity per
year, region and category
Group by
select d.year,
c.region,
p.category,
sum(s.quantity)quantity,
sum(s.amount)amount
from ex2_sales s
join ex2_product p on s.product = p.product
join ex2_customer c on s.customer = c.customer
join ex2_date d on s.the_date = d.the_date
group by d.year,
c.region,
p.category
This group by is static!
What if instead of by year you want it by month
I need another query!
12
Analytic views
13 © 2020 Oracle Corporation.
I Dati di Vendita
Analytic Views
• Create attribute dimension (Date, Product, Customer)
• Create hyerarchy (Date, Product, Customer)
• Create analytic view(s) (Sales)
14 © 2020 Oracle Corporation.
Date Attribute Dimension
create or replace attribute dimension ex2_date_attr_dim
using ex2_date
attributes (
the_date,
month,
quarter,
year
)
level the_date
key the_date
order by the_date
determines (month)
level month
key month
order by month
determines (quarter)
level quarter
key quarter
order by quarter
determines (year)
level year
key year
order by year;
Date Level
Month Level
Quarter Level
Year Level
create or replace hierarchy ex2_date_hier
using ex2_date_attr_dim
(
the_date
child of month
child of quarter
child of year
);
Attribute Dimension Hierarchy
Levels
15 © 2020 Oracle Corporation.
Customer Attribute Dimension
create or replace attribute dimension ex2_customer_attr_dim
using ex2_customer
attributes (
customer,
city,
region
)
level customer
key customer
order by customer
determines (city)
level city
key city
order by city
determines (region)
level region
key region
order by region;
Customer Level
City Level
Region Level
create or replace hierarchy ex2_customer_hier
using ex2_customer_attr_dim
(
customer
child of city
child of region
);
Attribute Dimension Hierarchy
Levels
16 © 2020 Oracle Corporation.
Product Attribute Dimension
create or replace attribute dimension ex2_product_attr_dim
using ex2_product
attributes (
product,
sub_category,
category
)
level product
key product
order by product
determines (sub_category)
level sub_category
key sub_category
order by sub_category
determines (category)
level category
key category
order by category;
Product Level
Sub Category Level
Category Level
create or replace hierarchy ex2_product_hier
using ex2_product_attr_dim
(
product
child of sub_category
child of category
);
Attribute Dimension Hierarchy
Livelli
17 © 2020 Oracle Corporation.
Sales Analytic View
(One of many we could do …)
create or replace analytic view ex2_sales_av
using ex2_sales
dimension by ( ex2_date_attr_dim
key the_date
references the_date
hierarchies (ex2_date_hier default),
ex2_product_attr_dim
key product
references product
hierarchies (ex2_product_hier default),
ex2_customer_attr_dim
key customer
references customer
hierarchies (ex2_customer_hier default)
)
measures (
quantity fact quantity,
quantity_year_prev AS (LAG(quantity) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year)),
quantity_diff_year_prev AS (LAG_DIFF(quantity) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year)),
quantity_diff_perc_year_prev AS (ROUND(100*LAG_DIFF_PERCENT(quantity) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL
year),2)),
--
amount fact amount,
amount_year_prev AS (LAG(amount) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year)),
amount_diff_year_prev AS (LAG_DIFF(amount) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year)),
amount_diff_perc_year_prev AS (ROUND(100*LAG_DIFF_PERCENT(amount) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year),2))
)
default measure amount;
Date Hierarchy
Analytic View Hierarchy
Measures
Product Hierarchy
Customer Hierarchy
18
Query an Analytic View
19 © 2020 Oracle Corporation.
Query an Analytic View
select ex2_date_hier.level_name date_type,
ex2_date_hier.member_name the_date,
ex2_date_hier.hier_order date_order,
amount,
amount_year_prev,
amount_diff_year_prev,
amount_diff_perc_year_prev
from ex2_sales_av
hierarchies (
ex2_date_hier
)
where ex2_date_hier.level_name in ('YEAR')
and ex2_date_hier.member_name in ('2021','2022')
order by ex1_data_hier.hier_order
Level Name , Member Name and Order
Measures
Only Date Hierarchy
Date Hier Order
For every Hierarchy at least a where condition
20 © 2020 Oracle Corporation.
Interrogare una Vista Analitica Vendita
select ex2_date_hier.level_name date_type,
ex2_date_hier.member_name the_date,
amount,
amount_year_prev
from ex2_sales_av
hierarchies (
ex2_date_hier
)
where ex2_date_hier.level_name in ('YEAR','QUARTER')
order by ex2_date_hier.hier_order
Raggruppamento Dinamico
Ho sia il totale per anno che per
trimestre
Nessuna aggregazione da scrivere qui, il group by non serve
21
Let’s simplify query with SQL Macro
22 © 2020 Oracle Corporation.
SQL Macro
• Wrap code inside a function
• The code returned is «pure» SQL non PLSQL
• You can create real parametric query
Transforms this … in this
With same performances
create or replace package body ex2_pkg is
function sales_av_mcr1(
p_customer_level in varchar2 default null,
p_product_level in varchar2 default null,
p_date_level in varchar2 default null,
p_customer in varchar2 default null,
p_product in varchar2 default null,
p_date in varchar2 default null
) return clob sql_macro is
begin
RETURN q'{
select ex2_date_hier.level_name date_type,
ex2_date_hier.member_name the_date,
ex2_date_hier.hier_order date_order,
ex2_customer_hier.level_name customer_type,
ex2_customer_hier.member_name customer,
ex2_customer_hier.hier_order customer_order,
ex2_product_hier.level_name product_type,
ex2_product_hier.member_name product,
ex2_product_hier.hier_order product_order,
amount,
amount_year_prev,
amount_diff_year_prev,
amount_diff_perc_year_prev
from ex2_sales_av
hierarchies (
ex2_date_hier,
ex2_customer_hier,
ex2_product_hier
)
where ( instr( ':' || nvl(p_customer_level,'ALL') || ':', ':' || ex2_customer_hier.level_name || ':' ) > 0 )
and ( instr( ':' || nvl(p_product_level,'ALL') || ':', ':' || ex2_product_hier.level_name || ':' ) > 0 )
and ( instr( ':' || nvl(p_date_level,'ALL') || ':', ':' || ex2_date_hier.level_name || ':' ) > 0 )
and ( instr( ':' || nvl(p_customer,'ALL') || ':', ':' || ex2_customer_hier.member_name || ':' ) > 0 )
and ( instr( ':' || nvl(p_product,'ALL') || ':', ':' || ex2_product_hier.member_name || ':' ) > 0 )
and ( instr( ':' || nvl(p_date,'ALL') || ':', ':' || ex2_date_hier.member_name || ':' ) > 0 )
}';
end sales_av_mcr1;
end ex2_pkg;
/
create or replace package ex2_pkg is
function sales_av_mcr1(
p_customer_level in varchar2 default null,
p_product_level in varchar2 default null,
p_date_level in varchar2 default null,
p_customer in varchar2 default null,
p_product in varchar2 default null,
p_date in varchar2 default null
) return clob sql_macro;
end ex2_pkg;
/
24 © 2020 Oracle Corporation.
Query an Analytic view with SQL Macro
select *
from ex2_pkg.sales_av_mcr1();
select *
from ex2_pkg.sales_av_mcr1(
p_date_level =>'YEAR',
p_date =>'2021:2022'
);
select *
from ex2_pkg.sales_av_mcr1(
p_date_level =>'YEAR:QUARTER',
p_date =>'2022:2022-1:2022-2:2022-3:2022-4'
)
order by date_order;
select *
from ex2_pkg.sales_av_mcr1(
p_date_level =>'YEAR',
p_date =>'2021:2022',
p_customer_level =>'REGION',
p_customer =>'Central'
);
select *
from ex2_pkg.sales_av_mcr1(
p_date_level =>'YEAR',
p_date =>'2021:2022',
p_product_level =>'CATEGORY',
p_product =>'Office Supplies'
);
select *
from ex2_pkg.sales_av_mcr1(
p_date_level =>'YEAR',
p_date =>'2021:2022',
p_customer_level =>'REGION',
p_customer =>'ALL',
p_product_level =>'CATEGORY',
p_product =>'Office Supplies'
);
A Low-cod Developer can use a pre-built SQL Macro
written by a PL/SQL developer
25
And in APEX ?
26 © 2020 Oracle Corporation.
Total Year
Total Quarter
27 © 2020 Oracle Corporation.
Total Customer
Total Region
28 © 2020 Oracle Corporation.
Total Product
Total Category
29 © 2020 Oracle Corporation.
30 © 2020 Oracle Corporation.
31 © 2020 Oracle Corporation.
Sorgente della Griglia Interattiva
32
Thank you!

More Related Content

What's hot

Oracle SQL Developer Tips and Tricks: Data Edition
Oracle SQL Developer Tips and Tricks: Data EditionOracle SQL Developer Tips and Tricks: Data Edition
Oracle SQL Developer Tips and Tricks: Data EditionJeff Smith
 
SOA for PL/SQL Developer (OPP 2010)
SOA for PL/SQL Developer (OPP 2010)SOA for PL/SQL Developer (OPP 2010)
SOA for PL/SQL Developer (OPP 2010)Lucas Jellema
 
(ZDM) Zero Downtime DB Migration to Oracle Cloud
(ZDM) Zero Downtime DB Migration to Oracle Cloud(ZDM) Zero Downtime DB Migration to Oracle Cloud
(ZDM) Zero Downtime DB Migration to Oracle CloudRuggero Citton
 
How to use source control with apex?
How to use source control with apex?How to use source control with apex?
How to use source control with apex?Oliver Lemm
 
IBM FileNet ECM Roadmap
IBM FileNet ECM RoadmapIBM FileNet ECM Roadmap
IBM FileNet ECM Roadmapbobj4172
 
Oracle Database Advanced Querying
Oracle Database Advanced QueryingOracle Database Advanced Querying
Oracle Database Advanced QueryingZohar Elkayam
 
Oracle RAC 19c - the Basis for the Autonomous Database
Oracle RAC 19c - the Basis for the Autonomous DatabaseOracle RAC 19c - the Basis for the Autonomous Database
Oracle RAC 19c - the Basis for the Autonomous DatabaseMarkus Michalewicz
 
Rola wiedzy we współczesne ekonomii
Rola wiedzy we współczesne ekonomiiRola wiedzy we współczesne ekonomii
Rola wiedzy we współczesne ekonomiiTomaszPoskrobko
 
2009 IVECO DAILY 4 Service Repair Manual
2009 IVECO DAILY 4 Service Repair Manual2009 IVECO DAILY 4 Service Repair Manual
2009 IVECO DAILY 4 Service Repair Manualjknmms ekdms
 
Polymorphic Table Functions in SQL
Polymorphic Table Functions in SQLPolymorphic Table Functions in SQL
Polymorphic Table Functions in SQLChris Saxon
 
Exadata Performance Optimization
Exadata Performance OptimizationExadata Performance Optimization
Exadata Performance OptimizationEnkitec
 
Cross-Validation Rules: Tips to Optimize your GL
Cross-Validation Rules: Tips to Optimize your GLCross-Validation Rules: Tips to Optimize your GL
Cross-Validation Rules: Tips to Optimize your GLeprentise
 
10 define workforce structures
10 define workforce structures10 define workforce structures
10 define workforce structuresmohamed refaei
 
Maximo Training - Work Management
Maximo Training - Work ManagementMaximo Training - Work Management
Maximo Training - Work ManagementBruno Portaluri
 
Generic Maximo Business Processes
Generic Maximo Business ProcessesGeneric Maximo Business Processes
Generic Maximo Business ProcessesMisha Jain
 
Oracle Fusion HCM Payroll Process Flow.pdf
Oracle Fusion HCM Payroll Process Flow.pdfOracle Fusion HCM Payroll Process Flow.pdf
Oracle Fusion HCM Payroll Process Flow.pdfFeras Ahmad
 
Hyperion FDM Admin. Guide
Hyperion FDM Admin. GuideHyperion FDM Admin. Guide
Hyperion FDM Admin. GuideIssam Hejazin
 
How to downscope your EBS upgrade project
How to downscope your EBS upgrade projectHow to downscope your EBS upgrade project
How to downscope your EBS upgrade projectpanayaofficial
 

What's hot (20)

Oracle SQL Developer Tips and Tricks: Data Edition
Oracle SQL Developer Tips and Tricks: Data EditionOracle SQL Developer Tips and Tricks: Data Edition
Oracle SQL Developer Tips and Tricks: Data Edition
 
SOA for PL/SQL Developer (OPP 2010)
SOA for PL/SQL Developer (OPP 2010)SOA for PL/SQL Developer (OPP 2010)
SOA for PL/SQL Developer (OPP 2010)
 
Oracle 索引介紹
Oracle 索引介紹Oracle 索引介紹
Oracle 索引介紹
 
(ZDM) Zero Downtime DB Migration to Oracle Cloud
(ZDM) Zero Downtime DB Migration to Oracle Cloud(ZDM) Zero Downtime DB Migration to Oracle Cloud
(ZDM) Zero Downtime DB Migration to Oracle Cloud
 
How to use source control with apex?
How to use source control with apex?How to use source control with apex?
How to use source control with apex?
 
IBM FileNet ECM Roadmap
IBM FileNet ECM RoadmapIBM FileNet ECM Roadmap
IBM FileNet ECM Roadmap
 
Oracle Database Advanced Querying
Oracle Database Advanced QueryingOracle Database Advanced Querying
Oracle Database Advanced Querying
 
Oracle RAC 19c - the Basis for the Autonomous Database
Oracle RAC 19c - the Basis for the Autonomous DatabaseOracle RAC 19c - the Basis for the Autonomous Database
Oracle RAC 19c - the Basis for the Autonomous Database
 
Rola wiedzy we współczesne ekonomii
Rola wiedzy we współczesne ekonomiiRola wiedzy we współczesne ekonomii
Rola wiedzy we współczesne ekonomii
 
2009 IVECO DAILY 4 Service Repair Manual
2009 IVECO DAILY 4 Service Repair Manual2009 IVECO DAILY 4 Service Repair Manual
2009 IVECO DAILY 4 Service Repair Manual
 
Polymorphic Table Functions in SQL
Polymorphic Table Functions in SQLPolymorphic Table Functions in SQL
Polymorphic Table Functions in SQL
 
Exadata Backup
Exadata BackupExadata Backup
Exadata Backup
 
Exadata Performance Optimization
Exadata Performance OptimizationExadata Performance Optimization
Exadata Performance Optimization
 
Cross-Validation Rules: Tips to Optimize your GL
Cross-Validation Rules: Tips to Optimize your GLCross-Validation Rules: Tips to Optimize your GL
Cross-Validation Rules: Tips to Optimize your GL
 
10 define workforce structures
10 define workforce structures10 define workforce structures
10 define workforce structures
 
Maximo Training - Work Management
Maximo Training - Work ManagementMaximo Training - Work Management
Maximo Training - Work Management
 
Generic Maximo Business Processes
Generic Maximo Business ProcessesGeneric Maximo Business Processes
Generic Maximo Business Processes
 
Oracle Fusion HCM Payroll Process Flow.pdf
Oracle Fusion HCM Payroll Process Flow.pdfOracle Fusion HCM Payroll Process Flow.pdf
Oracle Fusion HCM Payroll Process Flow.pdf
 
Hyperion FDM Admin. Guide
Hyperion FDM Admin. GuideHyperion FDM Admin. Guide
Hyperion FDM Admin. Guide
 
How to downscope your EBS upgrade project
How to downscope your EBS upgrade projectHow to downscope your EBS upgrade project
How to downscope your EBS upgrade project
 

Similar to ORACLE_23-03-31_en.pdf

How to Realize an Additional 270% ROI on Snowflake
How to Realize an Additional 270% ROI on SnowflakeHow to Realize an Additional 270% ROI on Snowflake
How to Realize an Additional 270% ROI on SnowflakeAtScale
 
Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Geoffrey De Smet
 
SQL coding at Sydney Measure Camp 2018
SQL coding at Sydney Measure Camp 2018SQL coding at Sydney Measure Camp 2018
SQL coding at Sydney Measure Camp 2018Adilson Mendonca
 
Data Modeling in Looker
Data Modeling in LookerData Modeling in Looker
Data Modeling in LookerLooker
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Johann de Boer
 
Tutorial - Learn SQL with Live Online Database
Tutorial - Learn SQL with Live Online DatabaseTutorial - Learn SQL with Live Online Database
Tutorial - Learn SQL with Live Online DatabaseDBrow Adm
 
Agile Database Development with JSON
Agile Database Development with JSONAgile Database Development with JSON
Agile Database Development with JSONChris Saxon
 
Company segmentation - an approach with R
Company segmentation - an approach with RCompany segmentation - an approach with R
Company segmentation - an approach with RCasper Crause
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENTLori Moore
 
Data Warehouses and Multi-Dimensional Data Analysis
Data Warehouses and Multi-Dimensional Data AnalysisData Warehouses and Multi-Dimensional Data Analysis
Data Warehouses and Multi-Dimensional Data AnalysisRaimonds Simanovskis
 
(ADV403) Dynamic Ad Perf. Reporting w/ Redshift: Data Science, Queries at Sca...
(ADV403) Dynamic Ad Perf. Reporting w/ Redshift: Data Science, Queries at Sca...(ADV403) Dynamic Ad Perf. Reporting w/ Redshift: Data Science, Queries at Sca...
(ADV403) Dynamic Ad Perf. Reporting w/ Redshift: Data Science, Queries at Sca...Amazon Web Services
 
Meetup Beleza na Web - Funções analíticas com SQL
Meetup Beleza na Web - Funções analíticas com SQLMeetup Beleza na Web - Funções analíticas com SQL
Meetup Beleza na Web - Funções analíticas com SQLBruno Paulino, MBA
 
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...Oleksandr Tarasenko
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Miguel González-Fierro
 
Write a banking program that simulates the operation of your local ba.docx
 Write a banking program that simulates the operation of your local ba.docx Write a banking program that simulates the operation of your local ba.docx
Write a banking program that simulates the operation of your local ba.docxajoy21
 
Love Your Database Railsconf 2017
Love Your Database Railsconf 2017Love Your Database Railsconf 2017
Love Your Database Railsconf 2017gisborne
 

Similar to ORACLE_23-03-31_en.pdf (20)

How to Realize an Additional 270% ROI on Snowflake
How to Realize an Additional 270% ROI on SnowflakeHow to Realize an Additional 270% ROI on Snowflake
How to Realize an Additional 270% ROI on Snowflake
 
Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)Hybrid rule engines (rulesfest 2010)
Hybrid rule engines (rulesfest 2010)
 
SQL coding at Sydney Measure Camp 2018
SQL coding at Sydney Measure Camp 2018SQL coding at Sydney Measure Camp 2018
SQL coding at Sydney Measure Camp 2018
 
Data Modeling in Looker
Data Modeling in LookerData Modeling in Looker
Data Modeling in Looker
 
Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015Digital analytics with R - Sydney Users of R Forum - May 2015
Digital analytics with R - Sydney Users of R Forum - May 2015
 
Tutorial - Learn SQL with Live Online Database
Tutorial - Learn SQL with Live Online DatabaseTutorial - Learn SQL with Live Online Database
Tutorial - Learn SQL with Live Online Database
 
Agile Database Development with JSON
Agile Database Development with JSONAgile Database Development with JSON
Agile Database Development with JSON
 
Company segmentation - an approach with R
Company segmentation - an approach with RCompany segmentation - an approach with R
Company segmentation - an approach with R
 
ADBMS ASSIGNMENT
ADBMS ASSIGNMENTADBMS ASSIGNMENT
ADBMS ASSIGNMENT
 
Data Warehouses and Multi-Dimensional Data Analysis
Data Warehouses and Multi-Dimensional Data AnalysisData Warehouses and Multi-Dimensional Data Analysis
Data Warehouses and Multi-Dimensional Data Analysis
 
(ADV403) Dynamic Ad Perf. Reporting w/ Redshift: Data Science, Queries at Sca...
(ADV403) Dynamic Ad Perf. Reporting w/ Redshift: Data Science, Queries at Sca...(ADV403) Dynamic Ad Perf. Reporting w/ Redshift: Data Science, Queries at Sca...
(ADV403) Dynamic Ad Perf. Reporting w/ Redshift: Data Science, Queries at Sca...
 
Meetup Beleza na Web - Funções analíticas com SQL
Meetup Beleza na Web - Funções analíticas com SQLMeetup Beleza na Web - Funções analíticas com SQL
Meetup Beleza na Web - Funções analíticas com SQL
 
Belajar SQL
Belajar SQLBelajar SQL
Belajar SQL
 
Opm mac subledger
Opm mac subledgerOpm mac subledger
Opm mac subledger
 
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
How to grow GraphQL and remove SQLAlchemy and REST API from a high-load Pytho...
 
Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...Running Intelligent Applications inside a Database: Deep Learning with Python...
Running Intelligent Applications inside a Database: Deep Learning with Python...
 
Write a banking program that simulates the operation of your local ba.docx
 Write a banking program that simulates the operation of your local ba.docx Write a banking program that simulates the operation of your local ba.docx
Write a banking program that simulates the operation of your local ba.docx
 
Data Warehouse Project
Data Warehouse ProjectData Warehouse Project
Data Warehouse Project
 
Love Your Database Railsconf 2017
Love Your Database Railsconf 2017Love Your Database Railsconf 2017
Love Your Database Railsconf 2017
 
2019 WIA - Data-Driven Product Improvements
2019 WIA - Data-Driven Product Improvements2019 WIA - Data-Driven Product Improvements
2019 WIA - Data-Driven Product Improvements
 

Recently uploaded

Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 

Recently uploaded (20)

Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 

ORACLE_23-03-31_en.pdf

  • 1. Oracle APEX & Oracle Analytic Views Ing. Roberto Capancioni 31st March 2023
  • 2. Chi Sono Ing. Roberto Capancioni –Sviluppo Oracle APEX –Board Member ITOUG Email: sviluppo@capancioni.com Linkedin: https://www.linkedin.com/in/robertocapancioni Web: https://capancioni.com
  • 10. Group by Amount and quantity per year, region and category
  • 11. Group by select d.year, c.region, p.category, sum(s.quantity)quantity, sum(s.amount)amount from ex2_sales s join ex2_product p on s.product = p.product join ex2_customer c on s.customer = c.customer join ex2_date d on s.the_date = d.the_date group by d.year, c.region, p.category This group by is static! What if instead of by year you want it by month I need another query!
  • 13. 13 © 2020 Oracle Corporation. I Dati di Vendita Analytic Views • Create attribute dimension (Date, Product, Customer) • Create hyerarchy (Date, Product, Customer) • Create analytic view(s) (Sales)
  • 14. 14 © 2020 Oracle Corporation. Date Attribute Dimension create or replace attribute dimension ex2_date_attr_dim using ex2_date attributes ( the_date, month, quarter, year ) level the_date key the_date order by the_date determines (month) level month key month order by month determines (quarter) level quarter key quarter order by quarter determines (year) level year key year order by year; Date Level Month Level Quarter Level Year Level create or replace hierarchy ex2_date_hier using ex2_date_attr_dim ( the_date child of month child of quarter child of year ); Attribute Dimension Hierarchy Levels
  • 15. 15 © 2020 Oracle Corporation. Customer Attribute Dimension create or replace attribute dimension ex2_customer_attr_dim using ex2_customer attributes ( customer, city, region ) level customer key customer order by customer determines (city) level city key city order by city determines (region) level region key region order by region; Customer Level City Level Region Level create or replace hierarchy ex2_customer_hier using ex2_customer_attr_dim ( customer child of city child of region ); Attribute Dimension Hierarchy Levels
  • 16. 16 © 2020 Oracle Corporation. Product Attribute Dimension create or replace attribute dimension ex2_product_attr_dim using ex2_product attributes ( product, sub_category, category ) level product key product order by product determines (sub_category) level sub_category key sub_category order by sub_category determines (category) level category key category order by category; Product Level Sub Category Level Category Level create or replace hierarchy ex2_product_hier using ex2_product_attr_dim ( product child of sub_category child of category ); Attribute Dimension Hierarchy Livelli
  • 17. 17 © 2020 Oracle Corporation. Sales Analytic View (One of many we could do …) create or replace analytic view ex2_sales_av using ex2_sales dimension by ( ex2_date_attr_dim key the_date references the_date hierarchies (ex2_date_hier default), ex2_product_attr_dim key product references product hierarchies (ex2_product_hier default), ex2_customer_attr_dim key customer references customer hierarchies (ex2_customer_hier default) ) measures ( quantity fact quantity, quantity_year_prev AS (LAG(quantity) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year)), quantity_diff_year_prev AS (LAG_DIFF(quantity) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year)), quantity_diff_perc_year_prev AS (ROUND(100*LAG_DIFF_PERCENT(quantity) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year),2)), -- amount fact amount, amount_year_prev AS (LAG(amount) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year)), amount_diff_year_prev AS (LAG_DIFF(amount) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year)), amount_diff_perc_year_prev AS (ROUND(100*LAG_DIFF_PERCENT(amount) OVER (HIERARCHY ex2_date_hier OFFSET 1 ACROSS ANCESTOR AT LEVEL year),2)) ) default measure amount; Date Hierarchy Analytic View Hierarchy Measures Product Hierarchy Customer Hierarchy
  • 19. 19 © 2020 Oracle Corporation. Query an Analytic View select ex2_date_hier.level_name date_type, ex2_date_hier.member_name the_date, ex2_date_hier.hier_order date_order, amount, amount_year_prev, amount_diff_year_prev, amount_diff_perc_year_prev from ex2_sales_av hierarchies ( ex2_date_hier ) where ex2_date_hier.level_name in ('YEAR') and ex2_date_hier.member_name in ('2021','2022') order by ex1_data_hier.hier_order Level Name , Member Name and Order Measures Only Date Hierarchy Date Hier Order For every Hierarchy at least a where condition
  • 20. 20 © 2020 Oracle Corporation. Interrogare una Vista Analitica Vendita select ex2_date_hier.level_name date_type, ex2_date_hier.member_name the_date, amount, amount_year_prev from ex2_sales_av hierarchies ( ex2_date_hier ) where ex2_date_hier.level_name in ('YEAR','QUARTER') order by ex2_date_hier.hier_order Raggruppamento Dinamico Ho sia il totale per anno che per trimestre Nessuna aggregazione da scrivere qui, il group by non serve
  • 21. 21 Let’s simplify query with SQL Macro
  • 22. 22 © 2020 Oracle Corporation. SQL Macro • Wrap code inside a function • The code returned is «pure» SQL non PLSQL • You can create real parametric query Transforms this … in this With same performances
  • 23. create or replace package body ex2_pkg is function sales_av_mcr1( p_customer_level in varchar2 default null, p_product_level in varchar2 default null, p_date_level in varchar2 default null, p_customer in varchar2 default null, p_product in varchar2 default null, p_date in varchar2 default null ) return clob sql_macro is begin RETURN q'{ select ex2_date_hier.level_name date_type, ex2_date_hier.member_name the_date, ex2_date_hier.hier_order date_order, ex2_customer_hier.level_name customer_type, ex2_customer_hier.member_name customer, ex2_customer_hier.hier_order customer_order, ex2_product_hier.level_name product_type, ex2_product_hier.member_name product, ex2_product_hier.hier_order product_order, amount, amount_year_prev, amount_diff_year_prev, amount_diff_perc_year_prev from ex2_sales_av hierarchies ( ex2_date_hier, ex2_customer_hier, ex2_product_hier ) where ( instr( ':' || nvl(p_customer_level,'ALL') || ':', ':' || ex2_customer_hier.level_name || ':' ) > 0 ) and ( instr( ':' || nvl(p_product_level,'ALL') || ':', ':' || ex2_product_hier.level_name || ':' ) > 0 ) and ( instr( ':' || nvl(p_date_level,'ALL') || ':', ':' || ex2_date_hier.level_name || ':' ) > 0 ) and ( instr( ':' || nvl(p_customer,'ALL') || ':', ':' || ex2_customer_hier.member_name || ':' ) > 0 ) and ( instr( ':' || nvl(p_product,'ALL') || ':', ':' || ex2_product_hier.member_name || ':' ) > 0 ) and ( instr( ':' || nvl(p_date,'ALL') || ':', ':' || ex2_date_hier.member_name || ':' ) > 0 ) }'; end sales_av_mcr1; end ex2_pkg; / create or replace package ex2_pkg is function sales_av_mcr1( p_customer_level in varchar2 default null, p_product_level in varchar2 default null, p_date_level in varchar2 default null, p_customer in varchar2 default null, p_product in varchar2 default null, p_date in varchar2 default null ) return clob sql_macro; end ex2_pkg; /
  • 24. 24 © 2020 Oracle Corporation. Query an Analytic view with SQL Macro select * from ex2_pkg.sales_av_mcr1(); select * from ex2_pkg.sales_av_mcr1( p_date_level =>'YEAR', p_date =>'2021:2022' ); select * from ex2_pkg.sales_av_mcr1( p_date_level =>'YEAR:QUARTER', p_date =>'2022:2022-1:2022-2:2022-3:2022-4' ) order by date_order; select * from ex2_pkg.sales_av_mcr1( p_date_level =>'YEAR', p_date =>'2021:2022', p_customer_level =>'REGION', p_customer =>'Central' ); select * from ex2_pkg.sales_av_mcr1( p_date_level =>'YEAR', p_date =>'2021:2022', p_product_level =>'CATEGORY', p_product =>'Office Supplies' ); select * from ex2_pkg.sales_av_mcr1( p_date_level =>'YEAR', p_date =>'2021:2022', p_customer_level =>'REGION', p_customer =>'ALL', p_product_level =>'CATEGORY', p_product =>'Office Supplies' ); A Low-cod Developer can use a pre-built SQL Macro written by a PL/SQL developer
  • 26. 26 © 2020 Oracle Corporation. Total Year Total Quarter
  • 27. 27 © 2020 Oracle Corporation. Total Customer Total Region
  • 28. 28 © 2020 Oracle Corporation. Total Product Total Category
  • 29. 29 © 2020 Oracle Corporation.
  • 30. 30 © 2020 Oracle Corporation.
  • 31. 31 © 2020 Oracle Corporation. Sorgente della Griglia Interattiva