Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> How to put a TOP 1 in a select
Hi!!
I was working with SQL Server 2000, and now the company decided to change
to Oracle. So I don't know much about Oracle, I am just reading a book and try
to find information on the net.
I am trying to do the next query, but I guess Oracle did not have the
function TOP. How can I do a TOP 1 in Oracle?
<FONT face="Courier New" color=#0000ff POINT-SIZE="9">select<FONT face="Courier New" color=#000000 POINT-SIZE="9"> TOP 1 ITEM, TRANS_DATE <FONT face="Courier New"color=#0000ff POINT-SIZE="9">from<FONT face="Courier New" color=#000000
POINT-SIZE="9"> ICTRANS <FONT face="Courier New" color=#0000ff POINT-SIZE="9">where<FONT face="Courier New" color=#000000 POINT-SIZE="9">
face="Courier New" color=#0000ff POINT-SIZE="9">AND<FONT face="Courier New" color=#000000 POINT-SIZE="9"> (TRANS_DATE <FONT face="Courier New" color=#0000ff POINT-SIZE="9">BETWEEN<FONT face="Courier New" color=#000000 POINT-SIZE="9"> (CURRENT_DATE-14)AND<FONT
face="Courier New" color=#0000ff POINT-SIZE="9">AND<FONT face="Courier New" color=#000000 POINT-SIZE="9"> (DOC_TYPE = <FONT face="Courier New" color=#ff0000 POINT-SIZE="9">'IS'<FONT face="Courier New" color=#000000 POINT-SIZE="9">)
face="Courier New" color=#0000ff POINT-SIZE="9">AND<FONT face="Courier New" color=#000000 POINT-SIZE="9"> (REASON_CODE = <FONT face="Courier New" color=#ff0000 POINT-SIZE="9">'VTCL'<FONT face="Courier New" color=#000000 POINT-SIZE="9">)
face="Courier New" color=#0000ff POINT-SIZE="9">order<FONT face="Courier New" color=#000000 POINT-SIZE="9"> <FONT face="Courier New" color=#0000ff POINT-SIZE="9">by<FONT face="Courier New" color=#000000POINT-SIZE="9"> QUANTITY