Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using ROW_NUMBER in a subquery

Pasquale Massimo ScorcaApr 8 2015 — edited Apr 8 2015

Hi,

I'm not very good in PL/SQL and I'd like to use the ROW_NUMBER function in a subquery.

I've tried to write this query:

select x.* from

(

SELECT ROW_NUMBER() over(partition by ext_dossier_id, to_char(audit_date, 'YYYYMMDD')

   order by EXT_DOSSIER_ID, audit_date desc) as Row_N,

      ,AUDIT_DATE

      ,AUDIT_ACTION

      ,EXTERNAL_DOSSIER_ID

      ,CONTRACT_ID

from dbschema.audit_ext_dossier

) X

where X.row_n = 1

but I haven't obtained the most recent record respect to the same data, also I've used ORDER BY audit_date desc in the OVER clause.

Audit_date is a datetime data and I want to get the most recent record in the same date.

Any helps to me, please?

Thanks

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 6 2015
Added on Apr 8 2015
15 comments
2,871 views