Oracle Advanced Query 1 Association query Group Query

Source: Internet
Author: User

Advanced Query

1. Related queries
Function: Can be queried across multiple tables

--Find out the name of the employee and the name of his department


Grammar:
Select columns, columns, columns
From table 1 Join table 2
On table 1 FOREIGN key = Table 2 PRIMARY key

2. Outer Joins


Left OUTER JOIN
On the left side of the association, even if there is no record to match on the right, the record on the left is also
Appears in the result set, and the right side is all displayed as null values.

Right-hand-out [outer join]
To the right of the association, even if there is no record to match on the left, the record on the right is also
Appears in the result set, and the left side is all displayed as null values.

3 Group queries
Definition: Use the built-in grouping function to query

The so-called grouping, is the view of the data "angle" is different.
That is, a class of values is the same as a group.

Grammar:
Select column name, group function (column name) ... from table name
Where condition
Group BY column
Having words
ORDER BY column

Grouping functions:
SUM ([distinct] column | expression | value) sum
AVG ([distinct] column | expression | value) averaging
Max (column | expression | value) to find the maximum value
Min (column | expression | value) to find the minimum value
Count ([distinct] column |*) number (contains null)


Note 1: Only columns that appear after group by [columns used as grouping criteria] are eligible
Write to the back of the select unless you use a group function to decorate it.

Note that both 2:having and where are conditional
Difference:
A group function cannot be used in a WHERE clause because it precedes GROUP by.
However, a group function can be used in a HAVING clause because it is after group by.

Oracle Advanced Query 1 Association query Group Query

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.