SQL for
Analysis, Reporting
and Modeling

Included in Oracle Database 12c Release 2 is a compelling array of analytical features and functions that are accessible through SQL and a new fast and efficient way to organize data using a dimensional model.

What's New in Database 12c Release 2

There are many new SQL features and enhancements in 12.2 that extend Oracle's flexible and comprehensive analytical framework:
  • Enhancements to LISTAGG to manage extremely large lists and control errors
  • New VALIDATE_CONVERSION function to detect if an input value can be converted to destination type
  • Enhancements to CAST function to return a user-specified value instead of an error
  • New approximate query processing for PERCENTILE and MEDIAN functions
  • New approximate processing to support reusable aggregations and materialized views
Overall, the SQL analytic functions and features in Oracle Database 12c Release 2 make it the most effective platform for delivering analytical results directly into operational, data warehousing and business intelligence projects. For more information see the following:


Whitepaper: SQL For Data Warehousing and Analysis: What's New In Oracle Database 12c Release 2

Presentation OpenWorld 2016, Oracle Database 12c Release 2: Top 10 Data Warehouse Features for Developers and DBAs


Also new in 12.2: Analytic Views which organize data using a dimensional model. They provide a fast and efficient way to create analytic queries over data stored in existing database tables and views. They allow you to easily add aggregations and calculations to data sets and to present data in views that can be queried with relatively simple SQL.


Presentation OpenWorld 2016, Analytic Views: A New Type of Database View for Simple, Powerful Analytics


Back to top


Try Database 12c Release 2 for free

Try out all of these exciting new features today by using the new free LiveSQL service. It provides you with instant access to a comprehensive collection of community scripts and structured tutorials covering the most important SQL features in Oracle Database 12c Release 2, including tutorials for analytic views.



Back to top


Overview of SQL for Analysis, Reporting and Modeling

The in-database analytical functions and features that are embedded inside the Oracle Database can be used to answer a wide variety of business problems. Developers and business users can access a wide range of analytic features and combine their results with other SQL queries and analytical pipelines to gain deeper insights.

Oracle's Database includes the following features:

  • Ranking
  • Analytical windows
  • Reporting aggregates
  • LAG/LEAD
  • FIRST/LAST
  • Statistics library
  • Hypothetical Rank and Distribution
  • Approximate query processing
  • Pattern matching
  • Modeling
  • Advanced aggregations
  • User defined functions

Standards Based SQL
In 1986, SQL became a standard of the American National Standards Institute (ANSI) and since then it has advanced to its current iteration, ANSI 2011. This standardization has two major benefits:
- the standard provides a high degree of application portability across different database systems without major code changes. In the field of data warehousing, BI tools are able to effectively support multiple types of SQL databases in a straightforward manner.

- the SQL standard has ensured continuity in application development. A SQL statement written thirty years ago continues to run today, without any modification to the SQL code.

Continuous Evolution
Oracle has a long history of embedding sophisticated SQL-based analytics within the Oracle Database.

Window functions, which are now a key analytical feature in the analysis of big data, were first introduced in Oracle 8i (1999) and many developers use them to manage complex big data requirements.

Oracle 10g (2003) introduced the SQL Model clause, which provides a spreadsheet-like what-if modeling framework aimed at business users and 12c introduced SQL pattern matching along with the HyperLogLog based approximate count distinct function.

Back to top

Key Benefits of SQL for
Analysis, Reporting and Modeling

The key benefits provided by Oracle's in-database analytical functions and features are:

Enhanced Developer Productivity - perform complex analyses with much clearer and more concise SQL code. Complex tasks can now be expressed using single SQL statement which is quicker to formulate and maintain, resulting in greater productivity.

Improved Query Speed - processing optimizations supported by in-database analytics enable significantly better query performance. Actions which before required self-joins or complex procedural processing may now be performed in native SQL.

Improved Manageability - ability to access a consolidated view of all data types and sources is simplified when applications share a common relational environment rather than a mix of calculation engines with incompatible data structures.

Minimized Learning Effort - SQL analytic functions minimize the need to learn new keywords because the syntax leverages existing well-understood keywords.

Industry standards based syntax - Oracle's features conform to ANSI SQL standard and are supported by a large number of independent software vendors.

Overview of Analytic Views

Analytic views organize data using a dimensional model. They allow you to easily add aggregations and calculations to data sets and to present data in views that can be queried with relatively simple SQL.

Like standard relational views, analytic views are metadata objects (that is, they do not store data) which can be queried using SQL. They access data from other database objects such as tables, views, and external tables and can join multiple tables into a single view.

Analytic views also:

  • Organize data using a rich business model that has dimensional and hierarchical concepts
  • Include system-generated columns with hierarchical data
  • Automatically aggregate data
  • Include embedded measure calculations that are easily defined using syntax based on the business model
  • Include presentation metadata
  • Hierarchically aware calculation expressions

Back to top

Key Benefits of
Analytic Views

The key benefits provided by Oracle's new analytic views are:

Simplified and faster application development - it is much easier to define calculations within analytic views than it is to write or generate complex SELECT statements.

Calculation rules are stored once - rules are stored in the database which provides end-users with greater freedom of choice in their use of reporting tools.

Caluclation consistentcy - because calculation rules are defined once and stored inside the database, they can be re-used by any number of applications