Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: question about the query..

RE: question about the query..

From: Daemen, Remco <R.Daemen_at_facent.nl>
Date: Wed, 05 Sep 2001 08:00:15 -0700
Message-ID: <F001.003835BD.20010905080620@fatcity.com>

How about:

select distinct ename,job,sal
from ( select ename,job,sal

       from   ( select * from emp order by salary desc )
       where  rownum <= 10000000
     );

Uses a lot of temp tablespace, though, and will not be very fast for large tables ... you should probably try one of the new functions of Oracle 8(i?). What verion do you use ?

HTH, Remco

-----Oorspronkelijk bericht-----
Van: Srinivas_Madala_at_circuitcity.com
[mailto:Srinivas_Madala_at_circuitcity.com] Verzonden: woensdag 5 september 2001 17:39 Aan: Multiple recipients of list ORACLE-L Onderwerp: question about the query..

Hi List
I have a question regarding a SQL query I am working on. I have a table named 'tmp_scores', with a column 'rank' and other columns. Rank varies from 1 to 12. I need to get the top 10 million records based on the rank.

I have used the logic behind the following query(to get top 4 salaried employees)



select ename,job,sal from emp e
where 4 > (select count(*) from emp
                      where e.sal<sal)

order by sal;

to get my task accomplished as below:

SELECT a.customer_id,
       a.first_name,
       a.last_name,
       a.carrier_route_code,
       a.unit_designator||'|'||a.street_pre_directional||'|'||
       a.primary_street_number||'|'||a.primary_street_name||'|'||
       a.street_post_directional||'|'||a.secondary_address_number||'|'||
       a.secondary_address_name "Street",
       city,
       a.state_code,
       a.postal_code,
       a.postal_code_extension,
       a.combined_score_demi_decil_rank

FROM tmp_stg_van_customer_details a
WHERE 10000000 > = (SELECT count(*) FROM
                      tmp_stg_van_customer_details
                      WHERE a.combined_score_demi_decil_rank <
combined_score_demi_decil_rank)
ORDER BY combined_score_demi_decil_rank;

I have issued the query and it has been running for the last three days without giving any error.
I am not able to conclude what to do.
Any help is highly appreciated.

Thanks in advance.
srinivas

--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author:
  INET: Srinivas_Madala_at_circuitcity.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).
--

Please see the official ORACLE-L FAQ: http://www.orafaq.com
--

Author: Daemen, Remco
  INET: R.Daemen_at_facent.nl
Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). Received on Wed Sep 05 2001 - 10:00:15 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US