Oracle how to do a limit? [duplicate]
up vote
0
down vote
favorite
This question already has an answer here:
How do I limit the number of rows returned by an Oracle query after ordering?
14 answers
I have to limit to 2 rows.
But can't do it for a SQL-Fetch.
select *
from employee;
oracle dbi
marked as duplicate by Thilo, Unheilig, APC, Kaushik Nayak, Community♦ Nov 20 at 13:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |
up vote
0
down vote
favorite
This question already has an answer here:
How do I limit the number of rows returned by an Oracle query after ordering?
14 answers
I have to limit to 2 rows.
But can't do it for a SQL-Fetch.
select *
from employee;
oracle dbi
marked as duplicate by Thilo, Unheilig, APC, Kaushik Nayak, Community♦ Nov 20 at 13:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
What is the version of Oracle being used?
– Used_By_Already
Nov 19 at 9:04
Why can't you useFETCH?
– Thilo
Nov 19 at 10:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
This question already has an answer here:
How do I limit the number of rows returned by an Oracle query after ordering?
14 answers
I have to limit to 2 rows.
But can't do it for a SQL-Fetch.
select *
from employee;
oracle dbi
This question already has an answer here:
How do I limit the number of rows returned by an Oracle query after ordering?
14 answers
I have to limit to 2 rows.
But can't do it for a SQL-Fetch.
select *
from employee;
This question already has an answer here:
How do I limit the number of rows returned by an Oracle query after ordering?
14 answers
oracle dbi
oracle dbi
edited Nov 19 at 10:49
APC
117k15115229
117k15115229
asked Nov 19 at 9:02
Talha
62
62
marked as duplicate by Thilo, Unheilig, APC, Kaushik Nayak, Community♦ Nov 20 at 13:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by Thilo, Unheilig, APC, Kaushik Nayak, Community♦ Nov 20 at 13:21
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
What is the version of Oracle being used?
– Used_By_Already
Nov 19 at 9:04
Why can't you useFETCH?
– Thilo
Nov 19 at 10:20
add a comment |
What is the version of Oracle being used?
– Used_By_Already
Nov 19 at 9:04
Why can't you useFETCH?
– Thilo
Nov 19 at 10:20
What is the version of Oracle being used?
– Used_By_Already
Nov 19 at 9:04
What is the version of Oracle being used?
– Used_By_Already
Nov 19 at 9:04
Why can't you use
FETCH?– Thilo
Nov 19 at 10:20
Why can't you use
FETCH?– Thilo
Nov 19 at 10:20
add a comment |
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
You can use something like this:
select *
from
( select *
from emp
order by data desc )
where ROWNUM <= 2;
add a comment |
up vote
0
down vote
You can change the query as:
select *
from
top_n_test
order by
num
fetch first 3 rows only;
The select first n rows only selects the first n rows.
In the question: "But can't do it for a SQL-Fetch." ...
– Used_By_Already
Nov 19 at 9:12
add a comment |
up vote
0
down vote
Well, the simplest way is to
select *
from employee
where rownum <= 2;
but the question is what exactly do you want to do with that.
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can use something like this:
select *
from
( select *
from emp
order by data desc )
where ROWNUM <= 2;
add a comment |
up vote
1
down vote
accepted
You can use something like this:
select *
from
( select *
from emp
order by data desc )
where ROWNUM <= 2;
add a comment |
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can use something like this:
select *
from
( select *
from emp
order by data desc )
where ROWNUM <= 2;
You can use something like this:
select *
from
( select *
from emp
order by data desc )
where ROWNUM <= 2;
answered Nov 19 at 10:19
Gauravsa
1,6811816
1,6811816
add a comment |
add a comment |
up vote
0
down vote
You can change the query as:
select *
from
top_n_test
order by
num
fetch first 3 rows only;
The select first n rows only selects the first n rows.
In the question: "But can't do it for a SQL-Fetch." ...
– Used_By_Already
Nov 19 at 9:12
add a comment |
up vote
0
down vote
You can change the query as:
select *
from
top_n_test
order by
num
fetch first 3 rows only;
The select first n rows only selects the first n rows.
In the question: "But can't do it for a SQL-Fetch." ...
– Used_By_Already
Nov 19 at 9:12
add a comment |
up vote
0
down vote
up vote
0
down vote
You can change the query as:
select *
from
top_n_test
order by
num
fetch first 3 rows only;
The select first n rows only selects the first n rows.
You can change the query as:
select *
from
top_n_test
order by
num
fetch first 3 rows only;
The select first n rows only selects the first n rows.
edited Nov 19 at 9:15
Wernfried Domscheit
23.5k42857
23.5k42857
answered Nov 19 at 9:06
Nandan Chaturvedi
607622
607622
In the question: "But can't do it for a SQL-Fetch." ...
– Used_By_Already
Nov 19 at 9:12
add a comment |
In the question: "But can't do it for a SQL-Fetch." ...
– Used_By_Already
Nov 19 at 9:12
In the question: "But can't do it for a SQL-Fetch." ...
– Used_By_Already
Nov 19 at 9:12
In the question: "But can't do it for a SQL-Fetch." ...
– Used_By_Already
Nov 19 at 9:12
add a comment |
up vote
0
down vote
Well, the simplest way is to
select *
from employee
where rownum <= 2;
but the question is what exactly do you want to do with that.
add a comment |
up vote
0
down vote
Well, the simplest way is to
select *
from employee
where rownum <= 2;
but the question is what exactly do you want to do with that.
add a comment |
up vote
0
down vote
up vote
0
down vote
Well, the simplest way is to
select *
from employee
where rownum <= 2;
but the question is what exactly do you want to do with that.
Well, the simplest way is to
select *
from employee
where rownum <= 2;
but the question is what exactly do you want to do with that.
answered Nov 19 at 10:11
Littlefoot
18.8k61333
18.8k61333
add a comment |
add a comment |
What is the version of Oracle being used?
– Used_By_Already
Nov 19 at 9:04
Why can't you use
FETCH?– Thilo
Nov 19 at 10:20