Oracle Aggregate Query
Oracle Database supports various aggregate queries, including but not limited to the following common aggregate queries:
1. COUNT: Used to calculate the number of specified columns or all rows.
Example:
Assuming there is a table named 'users' that contains the following columns: id, name, age.
SELECT COUNT(*) FROM users;
2. SUM: Used to calculate the sum of a specified column or all rows.
Example:
Assuming there is a table named 'orders' that contains the following columns: order_ ID, customer_ ID, order_ Amount.
SELECT SUM(order_amount) FROM orders;
3. AVG: Used to calculate the average value of a specified column or all rows.
Example:
Assuming there is a table named 'products' that contains the following columns: product_ Id, product_ Name, price.
SELECT AVG(price) FROM products;
4. MIN: Used to find the minimum value of a specified column or all rows.
Example:
Assuming there is a table named 'products' that contains the following columns: product_ Id, product_ Name, price.
SELECT MIN(price) FROM products;
5. MAX: Used to find the maximum value of a specified column or all rows.
Example:
Assuming there is a table named 'products' that contains the following columns: product_ Id, product_ Name, price.
SELECT MAX(price) FROM products;
6. GROUP BY: Used to group results by specified columns and perform aggregation calculations on each group.
Example:
Assuming there is a table named 'orders' that contains the following columns: order_ ID, customer_ ID, order_ Amount.
SELECT customer_id, SUM(order_amount) FROM orders GROUP BY customer_id;
The above are just some common aggregate query operations. In fact, Oracle Database also supports more complex aggregate query operations. The table structure and sample data in the above examples are for reference only and can be designed and filled in according to specific needs.