Difference between ANY and ALL operators

I am learning the basics of ANY and ALL operators.
Retrieving all employees in Dept 30 whose sal is greater than ANY employees in Dept 20
SQL> SELECT * FROM EMP;
     EMPNO ENAME           JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7369 SMITH           CLERK           7902 17-DEC-80        800                    20
      7499 ALLEN           SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD            SALESMAN        7698 22-FEB-81       1250        500         30
      7566 JONES           MANAGER         7839 02-APR-81       2975                    20
      7654 MARTIN          SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE           MANAGER         7839 01-MAY-81       2850                    30
      7782 CLARK           MANAGER         7839 09-JUN-81       2450                    10
      7788 SCOTT           ANALYST         7566 19-APR-87       3000                    20
      7839 KING            PRESIDENT            17-NOV-81       5000                    10
      7844 TURNER          SALESMAN        7698 08-SEP-81       1500          0         30
      7876 ADAMS           CLERK           7788 23-MAY-87       1100                    20
     EMPNO ENAME           JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7900 JAMES           CLERK           7698 03-DEC-81        950                    30
      7902 FORD            ANALYST         7566 03-DEC-81       3000                    20
      7934 MILLER          CLERK           7782 23-JAN-82       1300                    10
14 rows selected.
SQL> SELECT * FROM EMP WHERE DEPTNO=20;
     EMPNO ENAME           JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7369 SMITH           CLERK           7902 17-DEC-80        800                    20
      7566 JONES           MANAGER         7839 02-APR-81       2975                    20
      7788 SCOTT           ANALYST         7566 19-APR-87       3000                    20
      7876 ADAMS           CLERK           7788 23-MAY-87       1100                    20
      7902 FORD            ANALYST         7566 03-DEC-81       3000                    20
SQL> SELECT * FROM EMP WHERE DEPTNO=30;
     EMPNO ENAME           JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7499 ALLEN           SALESMAN        7698 20-FEB-81       1600        300         30
      7521 WARD            SALESMAN        7698 22-FEB-81       1250        500         30
      7654 MARTIN          SALESMAN        7698 28-SEP-81       1250       1400         30
      7698 BLAKE           MANAGER         7839 01-MAY-81       2850                    30
      7844 TURNER          SALESMAN        7698 08-SEP-81       1500          0         30
      7900 JAMES           CLERK           7698 03-DEC-81        950                    30
6 rows selected.
SQL> SELECT * FROM EMP
  2  WHERE SAL>ALL
  3  (SELECT SAL FROM
  4  EMP WHERE DEPTNO=20)
  5  AND DEPTNO=30;
no rows selected
SQL> SELECT * FROM EMP
  2   WHERE SAL>ANY
  3   (SELECT SAL FROM
  4   EMP WHERE DEPTNO=20)
  5   AND DEPTNO=30;
     EMPNO ENAME           JOB              MGR HIREDATE         SAL       COMM     DEPTNO
      7698 BLAKE           MANAGER         7839 01-MAY-81       2850                    30
      7499 ALLEN           SALESMAN        7698 20-FEB-81       1600        300         30
      7844 TURNER          SALESMAN        7698 08-SEP-81       1500          0         30
      7521 WARD            SALESMAN        7698 22-FEB-81       1250        500         30
      7654 MARTIN          SALESMAN        7698 28-SEP-81       1250       1400         30
      7900 JAMES           CLERK           7698 03-DEC-81        950                    30
6 rows selected.From a book by Damir Bersinic:
An easy shorthand enables you to remember the distinction between ANY and
ALL. If a query condition is >ANY, each row in the result set is greater than the lowest value returned. When a query is >ALL, each row in the result set is greater than the highest value returned.
He meant ; If a query condition is >ANY, each row in the result set is greater than the lowest value returned by the subquery. Didn't he?
I couldn't find ANY and ALL operators in 10g SQL Reference? Are these operators being replaced by anything?
Message was edited by:
for_good_reason

Look this
>ANY------- means more than minimum
Ex: sql> select empno,ename,job from emp
where sal>ANY(select sal from emp job='CLERK');
w/o using >ANY the query will be
sql>select empno,ename,job from emp
where sal>(select min(sal) from emp job='CLERK');
>ALL-------- means more than the maximum
Ex: sql> select empno,ename, job sal from emp
where sal> ALL(select Avg(sal) from emp Group by deptno);
w/o using >ALL the query will be
sql> select empno,ename, job sal from emp
where sal> (select max(Avg(sal)) from emp Group by deptno);
sandeep

Similar Messages

  • Difference between  exists and in operators in oracle?

    what is difference between exists and in operators in oracle?
    what is faster and why?

    Malli wrote:
    what is difference between exists and in operators in oracle?
    what is faster and why?Is this a homework question?
    Have you done any tests yourself to see which is faster?

  • Colour- strange difference between Lightroom and all other programs/windows

    Hello everyone,
    I have a strange problem with the colours in Lr. In the program everything looks good, the colours are the ones that i want to achieve, but when i export the pictures as jpeg (srgb), the tumbnails of these pictures seem to be fine (same colours as in Lr). However, when i open the jpeg (eg in picture viewer or in photoshop) all of the colours are different than the ones in Lr or the tumbnails. On a different computer, the jpegs have the same problem.
    Any idea how to resolve this problem? Can I change the colour management of Lr itself (not the external editors)?
    Thanx@

    OK.
    From LR in Develop module I press cmd e to create a TIFF to edit in PS CS3. Edit with LR adjustments is selected. After a while the TIFF appears beside the CR2 Canon 5d raw file.
    Still in LR flick between the two and the difference is readily apparent. I notice that all the tiff presets are at 0 i.e. in the develop module as I would expect them to be. But the TIFF image looks sharper and in areas of detail less saturated. I think the decrease in saturation is more a side effect of sharpening.
    The new TIFF opened in PS looks exactly the same as the TIFF in LR. But both are different from the raw file they were created from as seen from the LR develop module.
    In LR I have applied some masking and a moderate amount of sharpening to the CR2 raw file. I do note that applying sharpening in LR does not seem to change anything except the 1:1 and higher mags unless the sharpening is extreme. In other words I think the imnage as displayed at lower magnifications e.g. Fit to screen is not a realistic representation of the overall effect of sharpening, even when rendered on a large monitor (30") wide gamut monitor. If I am right this is a significant problem. I note that BibblePro perviews reflect the effect of sharpening on the overall image more accurately. (So it is possible.)
    (FWIW: My preview settings in LR are quality high, 2048 pixels.)
    EDIT: Yes I am correct, the images look the same at 1:1 but not at lower magnification. So guess the LR preview rendering machine does not quite match the preview rendered from the newly created TIFF.
    Still knowing this does not help, it just means what I see on the screen in LR at lower magnification than 1:1 is not accurate.

  • ANY and ALL Operators vs IN operator

    Hi all,
    i'm in the middle of learning the sql functions & operators ,now i'm learning about subqueries.
    i've learned abot the IN / NOT IN operator.now i'm kind of learning about the ANY & ALL .
    which the first question is : do i need to delve into this operators ? does anyone really use the any & all operator ,
    i'm asking cause ANY & ALL kind of confuses me vs the IN operator ?
    Thanks in Advanced
    Naama

    You must place an =, <>, <, >, <=, or >= operator before ANY/ALL.
    SQL> SELECT *
      2  FROM employee
      3  WHERE salary > ALL (2000, 3000, 4000);
    ID   FIRST_NAME LAST_NAME  START_DAT END_DATE      SALARY CITY       DESCRIPTION
    02   Alison     Mathews    21-MAR-76 21-FEB-86    6661.78 Vancouver  Tester
    03   James      Smith      12-DEC-78 15-MAR-90    6544.78 Vancouver  Tester
    06   Linda      Green      30-JUL-87 04-JAN-96    4322.78 New York   Tester
    07   David      Larry      31-DEC-90 12-FEB-98    7897.78 New York   Manager
    SQL> SELECT *
      2  FROM employee
      3  WHERE salary > ANY (2000, 3000, 4000);
    ID   FIRST_NAME LAST_NAME  START_DAT END_DATE      SALARY CITY       DESCRIPTION
    02   Alison     Mathews    21-MAR-76 21-FEB-86    6661.78 Vancouver  Tester
    03   James      Smith      12-DEC-78 15-MAR-90    6544.78 Vancouver  Tester
    04   Celia      Rice       24-OCT-82 21-APR-99    2344.78 Vancouver  Manager
    IN operator checks whether a variable value is in a set of comma-delimited values.
    SQL>
    SQL>  BEGIN
      2    IF 1 IN (1,2,3) THEN
      3     dbms_output.put_line('In the set.');
      4    END IF;
      5   END;
      6   /
    In the set.Edited by: user2361373 on Feb 24, 2011 1:20 AM

  • Hi All difference between abap and hr-abap urgent pls

    Hi All difference between abap and hr-abap urgent pls

    Hello,
    To add to the above points regarding infotypes
    Infotypes stand apart in  HR and manage a volume of data in HR domain..they are unique to HR module ranging from basic employee information to time management and finally the custom infotypes.....
    Payroll and other monetory activities related to an employee also form a vital part of the HR module....
    while considering Reports..in HR data is mainly with respect to infotypes and the concept of PAKEY...7 key fields which uniquely defines any record in an infotype is used..with Pernr(employee number),Begda(begindate) and Endda(enddate) form an integral part of the key..Based on the time constraints(1,2,3) of an infotype the keys are judged (to retrieve data from an infotype)
    In ABAP HR we also have lots of predefined function modules that can be used..eg:go to se37..put 'HR*' and press F4...
    finally to update an HR infotype record we use the function module hr operation rather than direct updates...also there are standard audit trail reports that monitors various activities such as insert/modify/delete operations on an hr infotype record...
    Pls revert back for clarity and reward if helpful
    Regards
    Byju

  • Could any one tell me what is the difference between swfloader and module loader?

    Hi  All,
                          Could any one tell me what is the difference between SWFLoader and Module Loader in Flex3 in detail?

    Hi,
    ModuleLoader is a kind of strange API that is really just intended to look like SwfLoader for modules that contain a single visual component, and hides most of the module loading infrastructure, which is all about class factories.
    What I mean by "only loaded once" is that if you have several places in the code that call the ModuleManager.getModule("url").load() call, it will only ever get loaded over the wire and interpreted once, subsequent "loads" will just re-dispatch pseudo-load events to the new client.  In other words, the class factory is a singleton for a given url. Unloading is a totally different story.  As you note, not everything is truly unloadable, because there may be lots of references to stuff in
    the module that will keep it alive and un-GC'ed.
    I suggest playing with the low-level API so that you understand the backing implementation, and this should help you understand the limits of ModuleLoader.
    The main difference between modules and applications is that modules have lower overhead, and they only ever get loaded once, no matter how many times you load them. If you're using the ModuleLoader API, keep in mind that you're losing about half the functionality of the module system.  I will assume that you are, because otherwise it would be obvious where to expose methods.  You might want to play around with the lower level ModuleManager API just to get a hang of what's going on - ModuleLoader is a pretty thin veneer over the lower API.                
                    Basically, what you want to do is to have your module implement an interface, say IModuleWhatever.
    Also try and refer to this link which was previously discussed in this forum..
    http://forums.adobe.com/message/74404
    Thanks,
    Bhasker

  • Difference between Insert and Insert all

    Hi,
    I tried to understand what INSERT ALL syntax is doing, but I cannot find any difference between INSERT and INSERT ALL.
    I replicated the test scenario using the data from the below mentioned URL:
    http://psoug.org/reference/insert.html
    I also did a google on finding up the difference between them, but could not find any...
    Please advice if both are same as I have planned to use INSERT statement with a WHEN clause if INSERT ALL is same as INSERT.
    Thanks!

    Hello
    The key difference is that INSERT ALL will allow you to insert into multiple different tables in a single statement whereas INSERT will only insert into 1 table. Each of the WHEN clauses allows a different table to be specified.
    SQL> create table t1
      2  (   id  number
      3  )
      4  /
    Table created.
    Elapsed: 00:00:00.01
    SQL> create table t2
      2  (   id  number
      3  )
      4  /
    Table created.
    Elapsed: 00:00:00.00
    SQL> create table t3
      2  (   id  number
      3  )
      4  /
    Table created.
    SQL> INSERT
      2  ALL
      3      WHEN id < 10 THEN
      4          INTO t1 VALUES(id)
      5      WHEN MOD(id,2) = 0 THEN
      6          INTO t2 VALUES(id)
      7      WHEN MOD(id,2) != 0 THEN
      8          INTO t3 VALUES(id)
      9  SELECT
    10      rownum id
    11  FROM
    12      dual
    13  CONNECT BY
    14      LEVEL <=20
    15  /
    29 rows created.
    Elapsed: 00:00:00.01
    SQL> select * from t1;
            ID
             1
             2
             3
             4
             5
             6
             7
             8
             9
    9 rows selected.
    Elapsed: 00:00:00.01
    SQL> select * from t2;
            ID
             2
             4
             6
             8
            10
            12
            14
            16
            18
            20
    10 rows selected.
    Elapsed: 00:00:00.00
    SQL> select * from t3
      2  /
            ID
             1
             3
             5
             7
             9
            11
            13
            15
            17
            19
    10 rows selected.
    Elapsed: 00:00:00.01So you can see that in a single statement, I've inserted all rows with an ID <10 into t1, all even numbered rows into t2 and all odd numbered rows into t3. This was also done with a single pass of the source table - in this case dual.
    David

  • What's the difference between shuffle and shuffle all?

    What's the difference between shuffle and shuffle all?

    Thanks but I have no playlists.  Perhaps you know then how the buttons work:
    ie. when "shuffle" is showing, does that mean it set to "shuffle all" and vice versa?
    the logic on these Iphones is whacky...
    Thanks!

  • Is there any difference between 10g and 11g M Views?

    Hi,
    I need to give a demo on and working examples of materialized views. The requirement is this: Master tables are in a 10g R2 DB, MV is in a 11g.
    I just create a DB Link in 11g to point to the 10g DB and then create the MV in 11g.
    Will there be any problems creating a 11g MV using 10 Master tables?
    My question is are there any significant differences between 10g and 11g MViews??
    Thanks & Regards,
    Channa.

    You have to be careful about your versions. 10g could be 10.1 or 10.2 11g could be 11.1 or 11.2
    I wouldn't have an 11.2 database with a database link against a 10.1 database.
    In fact, even with 10.2, I would try to ensure that I have a "high patchset" (10.2.0.4 or 10.2.0.5) although, in theory, 10.2.0.1 should also work.
    See Oracle Support article
    Client / Server / Interoperability Support Between Different Oracle Versions [ID 207303.1]
    Hemant K Chitale

  • Can anyone please let me know the differences between EDW and BI 7 if any

    Can anyone please let me know the differences between EDW and BI 7 if any.

    hi,
    As such their is no diff  between the to
    The Enterprise Data Warehouse (EDW) is a service offered by the Data Services Department of the Information Services and Technology Division.  EDW consolidates data from multiple sources in support of campus wide decision making and related information needs such as reporting, analysis, and planning.
    The vision for the EDW is to provide information that is secure, accurate, timely, consistent, integrated, appropriately detailed, well-organized, and easy to obtain so that people throughout the campus -- staff, faculty, researchers, and executive-level administrators -- will be better able to assess their needs, set priorities, understand the impact of change, and fulfill their programmatic responsibilities more efficiently.
    The major components of the existing Enterprise Data Warehouse are:
      BAIRS Financials
    BAIRS HRMS
    BIS
    Legacy BIS
    Student Data Warehouse Pilot 
    AND BI 7 is the latest version of the EDW which is currently in used in full fledged everywhere with lots of added functionality.
    Assign points if helpful.
    Regards,
    Amit

  • Can any one tell me the difference between VK11 and MR21

    Hi Folks,
    I have changed price of a material using VK12.
    When I go to the transaction MR21, it is still showing the old price.
    Can any one help what is the difference between VK11 and MR21.
    And i which scenarios these two were used?
    Thanks in Advance
    Gopi Krishna

    Hii,
    VK11: This is price master record to determine the sale price or discounts or freight or taxes which we going to charge to the final customer.  Through this transaction we will determine the price automatically either in sales or billing document.  These transaction is only applicable for sales & distribution module for determining the pricing for customers.
    The price determined through this we use in revenue realisation.
    MR21: Through this trnsaction Finance or Cost users upload the cost of the material.  The cost is
    Standard Cost or Moving average cost.
    Cost= Raw Material CostProcessing Cost(product process cost )Overheads(employee salaries)
    This cost is maintained at each material master in accounting view either standard cost or moving average cost.
    These cost is determined for every material movement within the company.
    Example: Production, transfer posting, goods issue- system post the quantity and at the same time system create an inventory entry i.e accounting entry for the transaction.  In this accounting entries, system consider the values from material master for generating accounting entry.
    If you upload production for 10 MT of material A and in material master if kept the cost of the material as 1000 then the accounting entry in production time as
                  Finish Goods Dr          10000
                            To Cost of Production Cr        10000
    These cost also determined sales transaction through VPRS condition type.
    Rewards if it helps
    Regards
    Goutham

  • Hi plz any body knows about difference between po_vendors and ap_vendors_v

    Any body knows about the difference between po_vendors and ap_vendors_v .plz send me the solution regarding this.
    thanks & regards
    Raghavendra
    09962651456
    [email protected]

    Any body knows about the difference between po_vendors and ap_vendors_v .plz send me the solution regarding this.
    thanks & regards
    Raghavendra
    09962651456
    [email protected]

  • Is there any differences between black and white ipod touch ?? only the color or there are hardware differences?

    is there any differences between black and white ipod touch ?? only the color or there are hardware differences?

    You're welcome.
    What?
    Sorry, but no. The parts are identical with the only difference being a white housing or a black housing.

  • Difference between the TABs  "All Content" and "Discussions" on the new forum?

    Hi,
    Does anyone know the difference between the TABs  "All Content" and "Discussions" on the new forum?  They seem to be the same.  I'm confused.
    Petey

    Petey,
    Though I was part of the forum update beta, there was some that we could not effectively test, plus some aspects (like "Like"), that some liked, but others did not. That sort of thing happens.
    Also, now that we have the full version, and all servers are synced, there will probably be things that the beta testers did not get to experience. We will all be learning, in the process too. Also remember, much of the new forum software was provided by Jive, and though many of us commented (pros and cons), only so much could be addressed. It was not quite like doing a beta on Adobe software, as there was a complete, separate layer in between.
    So far, what I see looks close to what we saw a few weeks (months?) ago. Now, I need to really put the real software through its paces, to see what got changed from then, until now.
    Good luck,
    Hunt

  • Is there any performance difference between unique and no unique index

    Hi,
    We are working with both databases Oracle and MS-SQL and we have an open channel to MS-SQL server core team.
    We got the word from them that there is a difference between unique and no unique index from the optimizer perspective, i.e. the optimizer knowing that the index is unique may choose a more suitable plan for running a specific query, we're still trying to find a specific example.
    Anyway, since we do not have an open channel to Oracle core, I thought maybe one of you guys knows something about Oracle optimizer behavior on this issue.
    I am interested verified answers from certified sources and not suggestions or thoughts.
    Thanks in advanced,
    Tal ([email protected]).

    Maybe, you will like to check this link for a similar question answered by Tom Kyte
    http://asktom.oracle.com/pls/ask/f?p=4950:8:385900000490041683::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:7641143144618,

Maybe you are looking for