w3resource
SQL exercises

SQL Subquery Exercises: Display the first and last name, salary and department ID for those employees whose department is located in the city London

SQL SUBQUERY : Exercise-46 with Solution

Write a query in SQL to display the first and last name, salary and department ID for those employees whose department is located in the city London.

Sample table: employees


Sample table: departments


Sample table: locations


Sample Solution:

SELECT first_name, last_name, salary, department_id 
  FROM employees
    WHERE department_id IN 
          (SELECT department_id 
            FROM departments 
             WHERE location_id = 
               (SELECT location_id 
                 FROM locations 
                   WHERE city = 'London'));

Sample Output:

first_name	last_name	salary	department_id
Susan		Mavris		6500.00	40

Practice Online


Query Visualization:

Duration:

Query visualization of Display the first and last name, salary and department ID for those employees whose department is located in the city London - Duration

Rows:

Query visualization of Display the first and last name, salary and department ID for those employees whose department is located in the city London - Rows

Cost:

Query visualization of Display the first and last name, salary and department ID for those employees whose department is located in the city London - Cost

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

Previous: Write a query in SQL to display the first and last name, salary, and department ID for those employees who earn less than the average salary, and also work at the department where the employee Laura is working as a first name holder.
Next: Write a query in SQL to display the city of the employee whose ID 134 and works there.

What is the difficulty level of this exercise?



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