Available in versions: Dev (3.22) | Latest (3.21) | 3.20 | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12
This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.
RATIO_TO_REPORT
Supported by ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The RATIO_TO_REPORT window function allows for getting the ratio of the corrent value in the window to the SUM over the window.
SELECT ID, ratio_to_report(ID) OVER () FROM BOOK;
create.select(
BOOK.ID,
ratioToReport(BOOK.ID).over())
.from(BOOK)
.fetch();
Producing:
+----+-----------------+ | id | ratio_to_report | +----+-----------------+ | 1 | 0.1 | | 2 | 0.2 | | 3 | 0.3 | | 4 | 0.4 | +----+-----------------+
Dialect support
This example using jOOQ:
ratioToReport(BOOK.ID).over()
Translates to the following dialect specific expressions:
Aurora Postgres, ClickHouse, CockroachDB, DB2, Databricks, DuckDB, Hana, Informix, MariaDB, MemSQL, MySQL, Postgres, Redshift, SQLDataWarehouse, SQLServer, Vertica, YugabyteDB
cast(BOOK.ID AS decimal) / sum(BOOK.ID) OVER ()
BigQuery, Exasol, H2, Oracle, Snowflake, Teradata
ratio_to_report(BOOK.ID) OVER ()
Firebird, Trino
cast(BOOK.ID AS decimal(38, 19)) / sum(BOOK.ID) OVER ()
SQLite
cast(BOOK.ID AS double) / sum(BOOK.ID) OVER ()
ASE, Access, Aurora MySQL, HSQLDB, Spanner, Sybase
/* UNSUPPORTED */
Generated with jOOQ 3.22. Support in older jOOQ versions may differ. Translate your own SQL on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!