SQLite Exercise: Display the last name, job, and salary for all employees whose job is that of a Programmer or a Shipping Clerk, and whose salary is not equal to $4,500, $10,000, or $15,000
Write a query to display the last name, job, and salary for all employees whose job is that of a Programmer or a Shipping Clerk, and whose salary is not equal to $4,500, $10,000, or $15,000.
Sample table : employees
SQLite Code :
SELECT last_name, job_id, salary
FROM employees
WHERE job_id IN ('IT_PROG', 'SH_CLERK')
AND salary NOT IN (4500,10000, 15000);
Output:
last_name job_id salary ---------- ---------- ---------- Hunold IT_PROG 9000 Ernst IT_PROG 6000 Austin IT_PROG 4800 Pataballa IT_PROG 4800 Lorentz IT_PROG 4200 Taylor SH_CLERK 3200 Fleaur SH_CLERK 3100 Sullivan SH_CLERK 2500 Geoni SH_CLERK 2800 Sarchand SH_CLERK 4200 Bull SH_CLERK 4100 Dellinger SH_CLERK 3400 Cabrio SH_CLERK 3000 Chung SH_CLERK 3800 Dilly SH_CLERK 3600 Gates SH_CLERK 2900 Perkins SH_CLERK 2500 Bell SH_CLERK 4000 Everett SH_CLERK 3900 McCain SH_CLERK 3200 Jones SH_CLERK 2800 Walsh SH_CLERK 3100 Feeney SH_CLERK 3000 OConnell SH_CLERK 2600 Grant SH_CLERK 2600
Relational Algebra Expression:

Relational Algebra Tree:

Practice SQLite Online
Model Database
Structure of 'hr' database :

Improve this sample solution and post your code through Disqus.
Previous: Write a query to display the first_name of all employees who have both an "b" and "c" in their first name.
Next: Write a query to display the last names of employees whose names have exactly 6 characters.
What is the difficulty level of this exercise?
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join