Oracle Advanced Queries

Source: Internet
Author: User

1. Eliminate duplicate rows
In the results of an Oracle query, there may be several rows in the same situation, so you can use distinct to eliminate duplicate rows.

Code Demo: Distinct eliminate duplicate rows


2. Null operation
If there is a missing data value in a record, it is the null value (null value). A null value is not equal to 0 or a space, and a null value is a value that is not assigned, unknown, or unavailable.
Columns of any data type can include null values unless the column is defined as a non-null or primary key.
In a query condition, a null value is used as a condition with IS null, and a non-null value is used for the condition with is not NULL.

Code Demo: Querying an EMP table for employees with no bonuses

Sql> SELECT Ename,job,sal,comm from EMP 2   WHERE sal<2000 and COMM are NULL;


3, in operation
In the WHERE clause, you can use the in operator to query the rows whose column values are in the specified list. The corresponding in operation also has not in, the same way, the result is the opposite.

Code Demo: in operation

Sql> SELECT ename,job,sal from EMP 2  WHERE JOB in (' salesman ', ' president ', ' ANALYST ');


4. Between ... And ...

In the WHERE clause, you can use the between operator to query the rows of column values that are contained within a specified range. The range specified by the Bwtween operation also includes the bounds.

Code Demo: between operation

Sql> SELECT ename,job,sal from EMP WHERE Sal between and 2000;

Oracle Advanced Queries

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.