w3resource

SQL Subquery Exercises: Display all the information of an employee whose salary and reporting person id is 3000 and 121 respectively

SQL SUBQUERY: Exercise-7 with Solution

From the following table, write a SQL query to find the employee whose salary is 3000 and reporting person’s ID is 121. Return all fields.

Sample table: employees


Sample Solution:

SELECT * 
FROM employees 
WHERE (salary,manager_id)=
(SELECT 3000,121);

Sample Output:

employee_id	first_name	last_name	email	phone_number	hire_date	job_id	salary	commission_pct	manager_id	department_id
187		Anthony		Cabrio		ACABRIO	650.509.4876	2007-02-07	SH_CLERK	3000.00	0.00	121		50

Pictorial Presentation:

SQL Subqueries: Display all the information of an employee whose salary and reporting person id is 3000 and 121 respectively

Practice Online


Query Visualization:

Duration:

Query visualization of Display all the information of an employee whose salary and reporting person id is 3000 and 121 respectively - Duration

Rows:

Query visualization of Display all the information of an employee whose salary and reporting person id is 3000 and 121 respectively - Rows

Cost:

Query visualization of Display all the information of an employee whose salary and reporting person id is 3000 and 121 respectively - Cost

Contribute your code and comments through Disqus.

Previous: From the following tables, write a SQL query to find all those employees who work in the Finance department. Return department ID, name (first), job ID and department name.
Next: From the following table, write a SQL query to find those employees whose ID matches any of the number 134, 159 and 183. Return all the fields.

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