Advanced oracle query and advanced Query

Source: Internet
Author: User

Advanced oracle query and advanced Query

1. eliminate duplicate rows
If several rows are the same in the Oracle query results, you can use DISTINCT to remove duplicate rows.

Code Demonstration: Remove duplicate rows in DISTINCT

SQL> SELECT DISTINCT DEPTNO FROM EMP;


2. NULL operation
If a record contains a missing data value, it is a NULL value ). A null value is not equal to 0 or a space. A null value is a value that is not assigned a value, unknown, or unavailable.
Any data type column can contain NULL values, unless the column is defined as non-empty or primary key.
In the query condition, the NULL value is null as the condition, and the non-NULL value is not null as the condition.

Code Demo: Query employees who do not receive bonuses in the EMP table

SQL> SELECT ENAME, JOB, SAL, COMM FROM EMP 2 WHERE SAL <2000 AND COMM IS NULL;


3. IN operation
IN the Where clause, you can use the IN operator to query the rows IN the specified list of column values. There is not in corresponding to the IN operation. The usage is the same, and the result is the opposite.

Code Demonstration: IN Operation

SQL> SELECT ENAME, JOB, SAL FROM EMP 2 WHERE job IN ('salesman', 'President ', 'analyst ');


4.... AND...

In the WHERE clause, you can use the BETWEEN operator to query rows whose column values are included in the specified range. The range specified by the BWTWEEN operation also includes the boundary.

Code Demonstration: BETWEEN Operation

SQL> SELECT ename, job, sal FROM EMP WHERE sal BETWEEN 1000 AND 2000;

 

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.