Skip to main content

Command Palette

Search for a command to run...

๐Ÿš€ Understanding Aggregate Functions in Oracle SQL (COUNT, AVG, SUM)

Updated
โ€ข2 min read
๐Ÿš€ Understanding Aggregate Functions in Oracle SQL (COUNT, AVG, SUM)

As part of my continued hands-on learning with Oracle Cloud, I explored aggregate functions in Oracle SQL. These functions are essential for analyzing data and generating meaningful insights from a database.

๐ŸŽฏ Objective

The goal of this activity was to:

  • Learn how to use aggregate functions

  • Perform calculations on database records

  • Understand data analysis using SQL

๐Ÿ’ป Step 1: Creating the Table

CREATE TABLE employees (
  emp_id NUMBER,
  emp_name VARCHAR2(50),
  salary NUMBER
);

๐Ÿงช Step 2: Inserting Data

INSERT INTO employees VALUES (1, 'Ali', 50000);
INSERT INTO employees VALUES (2, 'Ahmed', 70000);
INSERT INTO employees VALUES (3, 'Sara', 60000);

๐Ÿ”ข Step 3: Counting Records

SELECT COUNT(*) FROM employees;

This query returns the total number of employees.

๐Ÿ“Š Step 4: Calculating Average Salary

SELECT AVG(salary) FROM employees;

This gives the average salary of employees.

โž• Step 5: Calculating Total Salary

SELECT SUM(salary) FROM employees;

This returns the total salary of all employees.

๐Ÿ’ก What I Learned

  • How to use COUNT, AVG, and SUM functions

  • Performing calculations directly in Oracle SQL

  • Extracting meaningful insights from data

๐Ÿš€ Conclusion

This activity helped me understand how aggregate functions work in Oracle SQL and how they can be used to analyze structured data efficiently. These concepts are essential for real-world database applications.

1 views

More from this blog

๏ฟฝ

๐Ÿš€ Getting Started with Oracle Autonomous Database (Free Tier) โ€“ My First Hands-on Experience

15 posts