[Oracle]any, all parsing

Source: Internet
Author: User

Because they are seldom used, they are almost forgotten, but they can be useful to greatly simplify the syntax of some SQL, as for efficiency.
As the CCW says, they are no different from the exists, in and the like, and have specific problems to analyze
Where any and some are the same in meaning,
can replace each other.
Give a few examples to illustrate the use of all and any
1. Select * from TABLEA WHERE FLD > All (select FLD from TABLEA)
This is equivalent to
SELECT * from TABLEA WHERE FLD > (select MAX (FLD) from TABLEA)

2. Select * from TABLEA WHERE FLD > A (select FLD from TABLEA)
This is equivalent to
SELECT * from TABLEA WHERE FLD > (select MIN (FLD) from TABLEA)

3. Select * from TABLEA WHERE FLD = no (select FLD from TABLEA)
This is equivalent to
SELECT * from TABLEA WHERE FLD on (select FLD from TABLEA)

Finally, about having it is an operator for aggregate calculations, and where it has different meanings
When using group has the meaning of comparing records in each group,
In other words, it's a condition for selecting a set of data
Where is not related to grouping, it is the criteria for selecting a row of data
Like what
SELECT NAME, AVG (price) from STORE GROUP by NAME have avg (price) > 10
There's a place where there's no substitute.
As for efficiency, where is the processing done before the result set is generated,
and have to wait until the result set after the processing of the loop execution, natural efficiency is lower, so in only need to operate on the line, do not use having.

Http://www.cnblogs.com/Ronger/archive/2011/12/28/2305175.html

[Oracle]any, all parsing

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.