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

The usage of paging query in mysql Database

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

Share

Shulou(Shulou.com)05/31 Report--

This article is about the use of paging queries in mysql databases. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Purpose: to group rows by field

Select column,.. From table_name group by column1, column2; usage scenarios: commonly used in statistical situations, calculating average scores, statistical data, etc. Query the average salary of each department select dept, avg (salary) from emp group by dept; shows the average wage and minimum wage of each post in each department select dept, avg (salary), min (salary) from emp group by dept;select dept,job, avg (salary), min (salary) from emp group by dept,job Select dept,job,name, avg (salary), min (salary) from emp group by dept,job,name

Use the GROUP BY clause to group the results of a query

Select column,.. From table_name group by column having...

Having is used to continue filtering the grouping results.

The difference between where and having:

Where is used to query in raw data

Having is used to filter in the result set

When there are both where and having in a statement, execute where first and then having

Aggregate functions cannot appear in Where conditions, but can be found in having.

Show the name of the department whose average salary is less than 6000 and his average salary

Select dept, avg (salary) from emp group by dept having avg (salary)

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