Minus usage in Oracle (ZT) __oracle

Source: Internet
Author: User

The minus directive is used on two SQL statements. It first finds the results of the first SQL statement and then looks at the results of the second SQL statement. If so, the information is removed, not in the final results. If the result of the second SQL statement does not exist in the result of the first SQL statement, the data is discarded.

The syntax for minus is as follows:

[SQL Statement 1]
Minus
[SQL Statement 2]

We continue to use the same example:

Store_information table
Store_name Sales Date
Los Angeles $1500 jan-05-1999
San Diego $ jan-07-1999
Los Angeles $300 jan-08-1999
Boston $700 jan-08-1999


Internet Sales Form Date Sales
jan-07-1999 $
jan-10-1999 $535
jan-11-1999 $320
jan-12-1999 $750


And we need to know which days there is a store turnover and no network turnover. To achieve this, we use the following SQL statement:

SELECT Date from Store_information
Minus
SELECT Date from Internet_sales

Results:

Date
jan-05-1999
jan-08-1999


"jan-05-1999", "jan-07-1999", and "jan-08-1999" are the results of the "SELECT Date from Store_information". In this case, "jan-07-1999" is present in the result of the "SELECT Date from Internet_sales". So "jan-07-1999" is not in the final result.

Note that under the minus directive, different values are only listed once.

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.