View previous topic :: View next topic
|
Author |
Message |
prabhucs01 Warnings : 1 New User
Joined: 07 Mar 2005 Posts: 43
|
|
|
|
if there is a table with huge number of records and if i want to extract only first 3 records from the table, what query i have to provide to retreive first 3 records. no specific where conditions provided. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
if there is a table with huge number of records |
They are not called as records. They are ROWS
Give
Code: |
FETCH FIRST 3 ROWS ONLY |
after your query.. |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Use ORDER By along with what Sambhaji has suggested, otherwise you may get inconsistent results. |
|
Back to top |
|
|
lkhiger
New User
Joined: 28 Oct 2005 Posts: 89
|
|
|
|
If you use V9 you can do following
Code: |
select * from
(select t1.*, rownumber() over() colno from table t1) t2
where colno <= exactNo |
Lenny |
|
Back to top |
|
|
Ketan Varhade
Active User
Joined: 29 Jun 2009 Posts: 197 Location: Mumbai
|
|
|
|
Hi Lenny,
The query posted by you is quite confusing to me, Its better to provide a easy and understandable query to the OP,
I didnt got a word from the query what you have posted even my shop has V9, still.
What Anuj has said will get the desired result what OP wants.
Thanks |
|
Back to top |
|
|
lkhiger
New User
Joined: 28 Oct 2005 Posts: 89
|
|
|
|
Ketan Varhade wrote: |
Hi Lenny,
The query posted by you is quite confusing to me, Its better to provide a easy and understandable query to the OP,
I didnt got a word from the query what you have posted even my shop has V9, still.
What Anuj has said will get the desired result what OP wants.
Thanks |
No problem. I just shown an another way.
Lenny |
|
Back to top |
|
|
|