Avatar of Roberto Madro R.
Roberto Madro R.
Flag for United States of America

asked on 

The row_number in the subselect of an Oracle SQL Query is not picking the exact record.

I've got the query below against the table attached, I'm still getting mixed results as to the customer that has the product although I'm picking on the first instance of the transaction, the problem is only on days when the Model has exchanged hands on the same day.    

select
    modelnumber,
      releasenumber,
      deliverydate,
      deliverytime,
      customer
    from
    (select
    modelnumber,
      releasenumber,
      deliverydate,
      deliverytime,
      customer,
    row_number() over(partition by modelnumber order by deliverydate||deliverytime desc) rn from
    deliveries)
    where rn=1 And
      etc......
Oracle Database

Avatar of undefined
Last Comment
Roberto Madro R.

8/22/2022 - Mon