w3resource

SQL Subquery Exercises: Display the name for those employees who gets more salary than the employee whose id is 163

SQL SUBQUERY: Exercise-1 with Solution

From the following table, write a SQL query to find those employees who receive a higher salary than the employee with ID 163. Return first name, last name.

Sample table: employees


Sample Solution:


SELECT first_name, last_name 
FROM employees 
WHERE salary > 
( SELECT salary  
FROM employees 
WHERE employee_id=163
);

Sample Output:

first_name	last_name
Steven		King
Neena		Kochhar
Lex		De Haan
Nancy		Greenberg
Den		Raphaely
John		Russell
Karen		Partners
Alberto		Errazuriz
Gerald		Cambrault
Eleni		Zlotkey
Peter		Tucker
Janette		King
Clara		Vishney
Lisa		Ozer
Harrison	Bloom
Tayler		Fox
Ellen		Abel
Michael		Hartstein
Hermann		Baer
Shelley		Higgins

Pictorial Presentation:

SQL Subqueries: Display the name for those employees who gets more salary than the employee whose id is 163.

Practice Online


Query Visualization:

Duration:

Query visualization of Display the name for those employees who gets more salary than the employee whose id is 163 - Duration

Rows:

Query visualization of Display the name for those employees who gets more salary than the employee whose id is 163 - Rows

Cost:

Query visualization of Display the name for those employees who gets more salary than the employee whose id is 163 - Cost

Contribute your code and comments through Disqus.

Previous: SQL SUBQUERIES Exercises Home
Next: From the following table, write a SQL query to find those employees whose designation is the same as the employee whose ID is 169. Return first name, last name, department ID and job ID.

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