Introduction
In this project, you will learn how to use MySQL's built-in functions to retrieve relevant information from the employee table (emp
) in the personnel database. You will practice writing SQL queries to access and manipulate data in a relational database.
๐ Preview
MariaDB [personnel]> SOURCE /home/labex/project/multiple_line_function.sql;
+---------------+------------+------------+-------------+
| department_id | max_salary | min_salary | avg_salary |
+---------------+------------+------------+-------------+
| 20 | 3000.00 | 800.00 | 2175.000000 |
| 10 | 5000.00 | 1300.00 | 2916.666667 |
+---------------+------------+------------+-------------+
2 rows in set (0.001 sec)
๐ฏ Tasks
In this project, you will learn:
- How to access MySQL using the
sudo
command without a password
- How to import data from a SQL file into a MySQL database
- How to write a SQL query to retrieve the department number, maximum salary, minimum salary, and average salary for departments with an average salary of 2000 or more, and sort the results in descending order by department number
๐ Achievements
After completing this project, you will be able to:
- Understand how to use MySQL's built-in functions to perform complex data analysis
- Write SQL queries to retrieve and manipulate data from a relational database
- Apply your knowledge of SQL to solve real-world data management problems
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
mysql(("`MySQL`")) -.-> mysql/BasicKeywordsandStatementsGroup(["`Basic Keywords and Statements`"])
sql(("`SQL`")) -.-> sql/BasicSQLCommandsGroup(["`Basic SQL Commands`"])
sql(("`SQL`")) -.-> sql/DataManipulationandQueryingGroup(["`Data Manipulation and Querying`"])
mysql/BasicKeywordsandStatementsGroup -.-> mysql/source("`External Code Execution`")
sql/BasicSQLCommandsGroup -.-> sql/select("`SELECT statements`")
sql/DataManipulationandQueryingGroup -.-> sql/order_by("`ORDER BY clause`")
mysql/BasicKeywordsandStatementsGroup -.-> mysql/select("`Data Retrieval`")
mysql/BasicKeywordsandStatementsGroup -.-> mysql/use_database("`Database Selection`")
sql/BasicSQLCommandsGroup -.-> sql/insert("`INSERT INTO statements`")
sql/BasicSQLCommandsGroup -.-> sql/create_table("`CREATE TABLE statements`")
sql/DataManipulationandQueryingGroup -.-> sql/group_by("`GROUP BY clause`")
sql/DataManipulationandQueryingGroup -.-> sql/having("`HAVING clause`")
subgraph Lab Skills
mysql/source -.-> lab-301364{{"`MySQL Data Analysis`"}}
sql/select -.-> lab-301364{{"`MySQL Data Analysis`"}}
sql/order_by -.-> lab-301364{{"`MySQL Data Analysis`"}}
mysql/select -.-> lab-301364{{"`MySQL Data Analysis`"}}
mysql/use_database -.-> lab-301364{{"`MySQL Data Analysis`"}}
sql/insert -.-> lab-301364{{"`MySQL Data Analysis`"}}
sql/create_table -.-> lab-301364{{"`MySQL Data Analysis`"}}
sql/group_by -.-> lab-301364{{"`MySQL Data Analysis`"}}
sql/having -.-> lab-301364{{"`MySQL Data Analysis`"}}
end