Oracle 26ai: Aggregation Filters

Oracle 26ai introduces the FILTER clause, which lets you apply a WHERE condition directly inside an aggregate function, replacing the CASE workaround. If you want to follow along Add a new column to the HR.EMPLOYEES table called STATUS update some of the records to ACTIVE and the rest to INACTIVE. A script to make these […]

Oracle 26ai: RETURNING OLD and NEW Values

Oracle 26ai adds the OLD keyword to the existing RETURNING clause complementing the NEW keyword that was already there, and letting you capture both the before and after state of a row in a single atomic DML operation, with no extra SELECT required. The problem Audit logging, change tracking, and before/after comparisons all need both the old and new value of a column. […]

Oracle 26ai: GROUP BY ALL

Oracle 26ai introduces GROUP BY ALL which is syntactic sugar to tell Oracle to automatically include every non-aggregate column from your SELECT list in the grouping, so you don’t have add them again in the GROUP BY clause. The problem Standard SQL requires every non-aggregate column in the SELECT list to appear explicitly in the […]

Oracle 26ai: QUALIFY clause

Oracle AI Database 26ai introduces the QUALIFY clause which is a cleaner way to filter the results of analytic functions without a subquery or Common Table Expression (WITH clause). The problem Analytic functions such as RANK(), ROW_NUMBER(), and AVG() OVER (…) are evaluated after the WHERE clause. This means you cannot reference them directly in […]

Oracle 23ai: Table Value Constructors

Oracle Database 23ai introduced a useful SQL improvement which is the ability to use a VALUES(…) clause as an inline table within a query. The problem You need a small, hardcoded set of rows, a handful of status codes, a reference list or some test data and ideally without creating a temporary table or a view so […]