Database (4)

Source: Internet
Author: User

DQL (data Query Language)
A. Syntax
Select Column Name, ...
From table name
Where Condition expression
Order BY Column name (sort)
Eg:select Empno,ename,sal
From EMP
where empno=7788
Order BY Empno;
B. Alias as
Syntax: Column name as column alias
Eg:select ename as ' name ', sal as ' payroll ' from EMP;
C. Operations
1) Logical operation
And: Representation and (similar to && in Java)
Or: Represents or (similar to | | in Java) )
Not: Indicates an inverse
2) comparison operation
>,>=,<,<=,=,<>.! = (not equal to)
3) is null/is NOT null
Is null: Represents a column null
is NOT NULL: an example that represents a non-null
D. Constant query
Fixed line: Top N
Eg:select Top 5 empno,ename,comm from EMP;
Pro-rata: Top N percent
Eg:select Top 5 percent empno,ename,comm from EMP;
F. Sorting
Order BY column name, column name ... Asc/desc
ASC means: Descending
Desc: Ascending (default)

1 --SELECT ... 52 --From ... 13 --WHERE ... 24 --GROUP by ... 3 Press ... Grouping5 --Having ... 4 Packet filtering6 --ORDER by ... 67 8 --average salary for each department9 SELECTDEPTNO,AVG(SAL) fromEmpGROUP  byDEPTNO;Ten --Employee wages for employees with a salary portion greater than 1000 per department One SELECTDEPTNO,AVG(SAL) fromEmpWHERESAL> + GROUP  byDEPTNO; A --query is not available from January 1, 1981 to August 1, 1981 employee Information - SELECT *  fromEmpWHEREHireDate not between '1981-1-1'  and '1981-8-1';--Not to constrain the "reverse" operation of the condition
Example

Database (4)

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.