SQL Syntax

Hi,

I have this query tat outputs a result of more than 3million rows.. How can I set it to ouput only N number of rows?
Like the first 1000 or something like this...

select
dpsc.dsc_icid
from
dp_cad dpsc,
dp_cadprofle dpcp,
JM_Paage jampkg,
JM_CgeInstance jamcpi
where
dpsc.dpsc_id=jamcpi.dpsc_id and
jamcpi.jampkg_id=jampkg.jampkg_id and
jampkg.jampkg_id=6779 and
dpsc.dpcp_id=dpcp.dpcp_id and
dpcp_name='T7.0'
;

Tks,
Joao
joaotellesAsked:
Who is Participating?
 
sdstuberCommented:
select
dpsc.dsc_icid
from
dp_cad dpsc,
dp_cadprofle dpcp,
JM_Paage jampkg,
JM_CgeInstance jamcpi
where
dpsc.dpsc_id=jamcpi.dpsc_id and
jamcpi.jampkg_id=jampkg.jampkg_id and
jampkg.jampkg_id=6779 and
dpsc.dpcp_id=dpcp.dpcp_id and
dpcp_name='T7.0'
and rownum <= 1000
;
0
 
OP_ZaharinCommented:
- try this:

select
dpsc.dsc_icid
from
dp_cad dpsc,
dp_cadprofle dpcp,
JM_Paage jampkg,
JM_CgeInstance jamcpi
where
dpsc.dpsc_id=jamcpi.dpsc_id and
jamcpi.jampkg_id=jampkg.jampkg_id and
jampkg.jampkg_id=6779 and
dpsc.dpcp_id=dpcp.dpcp_id and
dpcp_name='T7.0'
WHERE ROWNUM < 1001;
0
 
sdstuberCommented:
better would be to apply an ORDER BY clause so you can determine which rows will be first

select dsc_icid from (
select
dpsc.dsc_icid
from
dp_cad dpsc,
dp_cadprofle dpcp,
JM_Paage jampkg,
JM_CgeInstance jamcpi
where
dpsc.dpsc_id=jamcpi.dpsc_id and
jamcpi.jampkg_id=jampkg.jampkg_id and
jampkg.jampkg_id=6779 and
dpsc.dpcp_id=dpcp.dpcp_id and
dpcp_name='T7.0'
order by dpsc.dsc_icid
)
where rownum <= 1000
0
 
OP_ZaharinCommented:
- opsss.. wrong and late. ignore mine :)
0
 
joaotellesAuthor Commented:
tks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.