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: ORACLE QUERY

Re: ORACLE QUERY

From: Mark Richard <mrichard_at_transurban.com.au>
Date: Mon, 11 Nov 2002 13:23:52 -0800
Message-ID: <F001.0050059C.20021111132352@fatcity.com>


Savita,

I assume the problem is the subquery...

You can't add the two select count(*) queries together like that. A valid option is to use a sum function like this:

select record_identifier from records where rownum<(40-(select sum(num) from (select count(*) num from customer_view union all select count(*) from unit view)));

The "union all" is important incase two counts are the same (union on its own would halve the result). The alias "num" is given to the first column so that there is something to enter in the sum clause.

Regards,

     Mark.

PS: There are other ways of doing this also.

                                                                                                                   
                    Savita                                                                                         
                    <savita_at_india.       To:     Multiple recipients of list ORACLE-L <ORACLE-L_at_fatcity.com>       
                    hp.com>              cc:                                                                       
                    Sent by:             Subject:     ORACLE QUERY                                                 
                    root_at_fatcity.c                                                                                 
                    om                                                                                             
                                                                                                                   
                                                                                                                   
                    11/11/2002                                                                                     
                    19:13                                                                                          
                    Please respond                                                                                 
                    to ORACLE-L                                                                                    
                                                                                                                   
                                                                                                                   




Hi All,

I want to know about one query.

I have two views and I want to get the sum of count of two view ex I have a query like

select record_identifier from records where rownum<(40-(select count(*) from customer_view+select count(*) from
unit_view));

But this is not working in oracle.

Is there any other way to do this without writing a function

--
Best Regards
- Savita
----------------------------------------------------
Hewlett Packard (India)
+91 80 2051288 (Phone)
847 1288 (HP Telnet)
----------------------------------------------------








<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Privileged/Confidential information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply e-mail or by telephone on (61 3) 9612-6999. Please advise immediately if you or your employer does not consent to Internet e-mail for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of Transurban City Link Ltd shall be understood as neither given nor endorsed by it. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<---->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Mark Richard INET: mrichard_at_transurban.com.au Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- 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 Mon Nov 11 2002 - 15:23:52 CST

Original text of this message

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