Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Oracle_071_lesson_p6

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Grouping function Group functions

Averaging by avg

Count asks for quantity

Max evaluation can be used for numbers, dates, characters

Min evaluation can be used for numbers, dates, characters

Sum summation

Listagg

Stddev

Variance

Count details:

Count (*) will return the total number of all existing rows in the table, including those with a value of null, while count (column name) will return the total number of all rows in the table except null (columns with default values will also be counted).

Distinct column name, the result will be the result after removing the value of null and duplicate data

Select avg (salary), max (salary), min (salary), sum (salary)

From employees

Where job_id like'% REP%'

Select count (*)

From employees

Where department_id=50

Select count (commission_pct)

From employees

Where department_id=50

Null rows do not participate in the calculation

GROUP BY grouping

Select department_id,avg (salary)

From employees

Group by department_id

Select department_id,avg (salary)

From employees

Group by department_id

Order by avg (salary)

This group by can be followed by order by, but the order by clause can only appear at the end.

Select avg (salary)

From employees

Group by department_id

However, the column name of group by does not have to be in the select clause

SELECT department_id, AVG (salary)

FROM employees

GROUP BY department_id

HAVING AVG (salary) > 8000

Grouping function cannot be added in where clause, and grouping function can only be added by using having clause.

Alias aliases cannot be placed in the group by clause

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report