w3resource
SQL exercises

SQL Exercises: Display the first name and last name of each employee, along with the name and sacntion amount for their department

SQL JOINS: Exercise-27 with Solution

Write a query in SQL to display the first name and last name of each employee, along with the name and sacntion amount for their department.

Sample table:emp_department


Sample table: emp_details


Sample Solution:

SELECT emp_details.emp_fname AS "First Name", emp_lname AS "Last Name", 
    emp_department.dpt_name AS "Department", 
     dpt_allotment AS "Amount Allotted"
       FROM emp_details 
         INNER JOIN emp_department
           ON emp_details.emp_dept = emp_department.dpt_code;

Output:

Display the name of each employee, along with  their sacntion amount and department name

Query Visualization:

Duration:

Query visualization of Display the first name and last name of each employee, along with the name and sacntion amount for their department - Duration

Rows:

Query visualization of Display the first name and last name of each employee, along with the name and sacntion amount for their department - Rows

Cost:

Query visualization of Display the first name and last name of each employee, along with the name and sacntion amount for their department - Cost

Practice Online


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a query in SQL to display all the data of employees including their department.
Next: Write a query in SQL to find the first name and last name of employees working for departments with a budget more than Rs.50000.

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming