﻿ SQL SUBQUERIES: Find all those employees who work in the Finance department - w3resource

# SQL Subquery Exercises: Display the department number, name, job and department name for all employees in the Finance department

## SQL SUBQUERY: Exercise-6 with Solution

From the following tables, write a SQL query to find all those employees who work in the Finance department. Return department ID, name (first name), job ID and department name.

Sample table: employees

Sample table: departments

Sample Solution:

``````SELECT e.department_id, e.first_name, e.job_id , d.department_name
FROM employees e , departments d
WHERE e.department_id = d.department_id
AND  d.department_name = 'Finance';
``````

Sample Output:

```department_id	first_name	job_id		department_name
100		Nancy		FI_MGR			Finance
100		Daniel		FI_ACCOUNT		Finance
100		John		FI_ACCOUNT		Finance
100		Ismael		FI_ACCOUNT		Finance
100		Jose Manuel	FI_ACCOUNT		Finance
100		Luis		FI_ACCOUNT		Finance
```

Relational Algebra Expression:

Relational Algebra Tree:

Pictorial Presentation:

## Query Visualization:

Duration:

Rows:

Cost:

Test your Programming skills with w3resource's quiz.

What is the difficulty level of this exercise?

﻿

## SQL: Tips of the Day

"where 1=1" statement?

It's usually when folks build up SQL statements.

When you add and value = "Toyota" you don't have to worry about whether there is a condition before or just WHERE.

Ref: https://bit.ly/3cayyhJ