Jarvis
Jarvis

Reputation: 25

How to choose specific rows in an sql query?

I have a table with 10 rows, i want to the query to view only one row. For example the 5th row. How can i do that. ROWNUM and LIMIT did not work for me, any help?

if i use rownum clause i get this

select * from final_inv  where rownum<=3 
CATEGORY    ITEM    QTY AVG_PRICE
Rice    Lal Quila   50  50
Spices  Chat Masala 1   200
Spices  Bay Leaf    -23 400

I want to only view one row of my choice out of 10. How to do that?

Upvotes: 1

Views: 418

Answers (1)

Multisync
Multisync

Reputation: 8797

select CATEGORY, ITEM, QTY AVG_PRICE from (
  select CATEGORY, ITEM, QTY AVG_PRICE, ROWNUM RW 
  from final_inv 
) where RW = 5;

Upvotes: 2

Related Questions