Mahesh Peiris

Case Study: MySQL employees dataset

Project Overview

Basic MySQL query on employee dataset. Please find more information about employee dataset on here.

Structure of the MySQL employee dataset.

SELECT * FROM TableName can use to select the all the data from any table.

We can use “concat” to join two columns in the tables.

Let’s group employee’s salaries by each year.

We can add average salary to the results by adding “AVG(salary) AS Average_Salary”

We can join employees and salaries tables by using the “JOIN” statement.

Using two join statements.

Let’s select the total salaries for each year only for the male employees.

Subquery is a query nested within another query such as SELECT, INSERT, UPDATE or DELETE. In addition, a subquery can be nested inside another subquery.

To combine conditions, we can use ‘AND’

Difference between natural join and inner join is that natural join will avoid the repeated column and not required to use ‘ON’.

LEFT JOIN returns all the rows from the left table. Where no matches have been found in the table on the right, NULL is returned.

Use of NOT EQUAL to select former employees.

Same results from different queries.

Few charts using Power BI for employee dataset (can directly query the MySQL employee database using Power BI inbuild MySQL connection.) Power BI file can be download here.

Complete MySQL file can be download here.

Want me to help with your project?