In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
It is believed that many inexperienced people have no idea about how to use the GROUP BY clause in Oracle database. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
Use of the GROUP BY clause in the Oracle database: the GROUP BY clause can be used to group rows into multiple parts with the same column values. For example, the following query groups the rows in the products table into the same parts of product_type_id:
SELECT product_type_id
FROM products
GROUP BY product_type_id
Note that each set of rows with the same product_type_id has a row of return values in the result set, for example, a product with a product_type_id of 1 has a row of results, a product with a product_type_id of 2 has a row of results, and so on. Records with product_type_id 1 in the products table actually have two rows, and records with product_type_id 2 actually have four rows. These rows are grouped into different parts, each product_type_id has a part, the part contains two lines, the second part contains four lines, and so on.
1. Use multiple columns in grouping
Multiple columns can be specified in the GROUP BY clause. The GROUP BY clause shown below contains the product_id and customer_id columns in the purchases table:
SELECT product_id,customer_id
FROM purchases
GROUP BY product_id,customer_id
two。 Row grouping using aggregate functions
Row grouping can use aggregate functions. The aggregate function calculates the rows in each group and calculates for the rows in each group, and does not return a result for each set of rows. Aggregate functions that can be used freely in GROUP BY statements, and note that if there is a null value, the COUNT () function will ignore it.
3. Sort groups using the ORDER BY clause
By default, the GROUP BY clause sorts rows in ascending order based on the values of the grouped columns. Note that the SELECT clause does not necessarily contain the columns used in the GROUP BY clause.
After reading the above, have you mastered how to use the GROUP BY clause in the Oracle database? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.