My Oracle Support Banner

Perceived 'Wrong Results' Using ROWNUM with DISTINCT or ORDER BY (Doc ID 1461173.1)

Last updated on MARCH 03, 2022

Applies to:

Oracle Database - Personal Edition - Version 8.0.3.0 and later
Oracle Database - Enterprise Edition - Version 8.0.3.0 and later
Oracle Database - Standard Edition - Version 8.0.3.0 and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.

Symptoms

A select statement using 'DISTINCT' or 'GROUP BY' and a 'ROWNUM' predicate is returning fewer rows than expected.

For example, the following query might return only 10 rows even when there are at least 100 distinct values in the table:

Cause

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Symptoms
Cause
Solution
References


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.