检索最新的行-Oracle 12c之前的版本 [英] Retrieve the most recent row - pre- Oracle 12c

查看:85
本文介绍了检索最新的行-Oracle 12c之前的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请耐心等待,因为我是这一切的新手.

Please bear with me as I am new to all this.

我的查询是,我有下表,我正在尝试针对该订单检索最新的NOTE_PAD.NOTE_TEXT. 该表格的示例如下.

My query is, I have the following table and I am attempting to retrieve the most recent NOTE_PAD.NOTE_TEXT against the order. Example of how the table looks like is below.

下表中的数据是通过将两个单独的表连接在一起而获得的. 对于该示例,我已使用以下语法进行连接,并且由于该数据库中有很多订单,因此本示例仅检索了特定的订单号(867318).

The data in the below table is obtained from joining two separate tables. I have used the following syntax for the join and retrieved only a specific order number for this example (867318) as there are many orders in the data base.

不确定我是否已经足够清楚,但是如果不能让我知道是否需要任何特定信息,我会尽力提供. 如前所述,请耐心等待,因为我完全不熟悉

Not certain if I’ve made it clear enough, but if not let me know if there is any specific information needed and I will try my best to provide. As mentioned please bear with me as I am totally new to this 

SQL语法:

SELECT ORDER_TYPE,
       ORDER_NUMBER,
       ORDER_LINE,
       NOTE_PAD.CREATED_DATE
  FROM ORDER_AWB INNER JOIN
       NOTE_PAD
       ON ( "ORDER_AWB"."NOTES" = "NOTE_PAD"."NOTES" )
WHERE ( "ORDER_AWB"."ORDER_NUMBER" = '867318' )

使用以上语法时的表结果示例:

Example of table result when above syntax is used:

推荐答案

对于Oracle DB 12c之前的版本,此方法应该有效

For an Oracle DB pre 12c this should work

SELECT * FROM
  (
  SELECT ORDER_TYPE,
         ORDER_NUMBER,
         ORDER_LINE,
         NOTE_PAD.CREATED_DATE
  FROM ORDER_AWB INNER JOIN
         NOTE_PAD ON ( "ORDER_AWB"."NOTES" = "NOTE_PAD"."NOTES" )
  WHERE ( "ORDER_AWB"."ORDER_NUMBER" = '867318' )
  ORDER BY NOTE_PAD.CREATED_DATE DESC
  )
WHERE ROWNUM <= 1

这篇关于检索最新的行-Oracle 12c之前的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆