Introduction
In this project, you will learn how to calculate the average salary for each department in a database and display the results in descending order using SQL queries.
👀 Preview
MariaDB [edusys]> SOURCE ~/project/singleTableQuery.sql
+------------+--------------+
| dept_name | avg_salary |
+------------+--------------+
| Physics | 91000.000000 |
| Finance | 85000.000000 |
| Elec. Eng. | 80000.000000 |
| Comp. Sci. | 77333.333333 |
| Biology | 72000.000000 |
| History | 61000.000000 |
| Music | 40000.000000 |
+------------+--------------+
7 rows in set (0.001 sec)
🎯 Tasks
In this project, you will learn:
- How to start the MySQL server and import a database
- How to write an SQL query to group data by department and calculate the average salary
- How to order the results in descending order based on the average salary
🏆 Achievements
After completing this project, you will be able to:
- Understand how to use SQL's
SELECT
,FROM
,WHERE
,GROUP BY
, andORDER BY
clauses to perform data analysis - Implement a SQL query to calculate and display the average salaries per department in descending order
- Apply your SQL knowledge to solve real-world data analysis problems