SQL Exercises: Display all the data of employees including their department
SQL JOINS: Exercise-26 with Solution
From the following tables write a SQL query to display all the data of employees including their department.
Sample table:emp_department
Sample table: emp_details
Sample Solution:
SELECT emp_idno, A.emp_fname AS "First Name", emp_lname AS "Last Name",
B.dpt_name AS "Department", emp_dept, dpt_code, dpt_allotment
FROM emp_details A
INNER JOIN emp_department B
ON A.emp_dept = B.dpt_code;
Output of the Query:
emp_idno First Name Last Name Department emp_dept dpt_code dpt_allotment 631548 Alan Snappy RD 27 27 55000 839139 Maria Foster IT 57 57 65000 127323 Michale Robbin IT 57 57 65000 526689 Carlos Snares Finance 63 63 15000 843795 Enric Dosio IT 57 57 65000 328717 Jhon Snares Finance 63 63 15000 444527 Joseph Dosni HR 47 47 240000 659831 Zanifer Emily HR 47 47 240000 847674 Kuleswar Sitaraman IT 57 57 65000 748681 Henrey Gabriel HR 47 47 240000 555935 Alex Manuel IT 57 57 65000 539569 George Mardy RD 27 27 55000 733843 Mario Saule Finance 63 63 15000
Practice Online
Query Visualization:
Duration:
Rows:
Cost:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous: From the following tables write a SQL query to find the most expensive product of each company. Return pro_name, pro_price and com_name.
Next: From the following tables write a SQL to display the first name and last name of each employee, along with the name and sanction amount for their department.
Test your Programming skills with w3resource's quiz.
What is the difficulty level of this exercise?
SQL: Tips of the Day
SQL Server SELECT into existing table.
INSERT INTO dbo.TABLETWO SELECT col1, col2 FROM dbo.TABLEONE WHERE col3 LIKE @search_key
This assumes there's only two columns in dbo.TABLETWO - you need to specify the columns otherwise:
INSERT INTO dbo.TABLETWO (col1, col2) SELECT col1, col2 FROM dbo.TABLEONE WHERE col3 LIKE @search_key
Database: SQL Server
Ref: https://bit.ly/3y6tpA3
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework