Link to home
Start Free TrialLog in
Avatar of joaotelles
joaotellesFlag for United States of America

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Sean Stuber
Sean Stuber

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
- 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;
Avatar of Sean Stuber
Sean Stuber

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
- opsss.. wrong and late. ignore mine :)
Avatar of joaotelles

ASKER

tks