Oracle Section 2nd Filtering and sorting data

Source: Internet
Author: User

Lessonaim

While retrieving data from the database, you may need to restrict the rows of data that is displayed or specify The order in which the rows is displayed.

This lesson explains the SQL statements, Youuse to perform these actions.


? filter rows in the query.
? sort the rows in the query.

SELECT *| {[DISTINCT] column|expression [alias],...}

from Table

[WHERE condition (s)];

?WHEREclause follows fromclauses。


Select employee_id , last_name , job_id , department_id

From Employees

WHERE department_id = +;




?characters and dates to be included in thesingle quotation marksin。?character case sensitive, date format sensitive。

SELECT last_name , job_id , department_id

From Employees

WHERE last_name = ' Whalen ';


SELECT last_name , hire_date , department_id

From Employees

WHERE hire_date = ' 7-6 Month -1994 '

The date is written in a specific format!



SELECT last_name , Salary

From Employees

WHERE Salary <= 3000;






1.

SELECT last_name , Salary

From Employees

WHERE salary between 2500 and 3500;


2.

SELECT employee_id , last_name , salary, manager_id

From Employees

WHERE manager_id In (101, 201);


? Use the like operation to select a similar value? The selection criteria can contain characters or numbers: –% represents 0 or more characters(any of the characters)。_represents a character

3.

SELECT first_name

From Employees

WHERE first_name Like ' s% ';



4.

SELECT last_name

From Employees

WHERE last_name Like ' _o% ';



? You can useESCAPEIdentifiers select '% ' and ' _ ' symbols.

? avoidance of special symbols:using escape characters。 For example: convert [%] to [\%], [_] to [\_], and then add [ESCAPE '].

SELECT job_id

from Job s

WHERE job_id Like ' it\_ % ' escape ' \ ' ;


5.

Null value is determined using is (not)null .


SELECT last_name , manager_id

From Employees

WHERE manager_id is NULL;








Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Oracle section 2nd filters and sorts data

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.