Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle gets the first piece of data

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

An example of sql for fetching the first piece of data is as follows:

Http://www.360doc.com/showweb/0/0/860281883.aspx

SELECT * FROM tableName where fd_rt ='A'--and rownum=1 ORDER BY fd_date DESC

Normally, the first piece of data should be 16bf4eb91606de5e0ff61f94d0f8f20f

The result of using this sql directly with the condition after where is as follows

SELECT * FROM tableName where fd_rt ='A'

And rownum=1

ORDER BY fd_date DESC

But the query result is the second piece of data.

Zhengzhou Infertility Hospital: http://www.xbzztj.com/

The correct way to use it is:

SELECT t.* from (SELECT * FROM tableName where fd_rt ='A' ORDER BY fd_date DESC) t WHERE rownum = 1

The query result of rownum as a pseudo column is actually:

SELECT tableName. *, rownum FROM tableName where fd_rt ='A'--and rownum=1 ORDER BY fd_date DESC

SELECT t.charting Rownum from (SELECT * FROM tableName where fd_rt ='A' ORDER BY fd_date DESC) t

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report