Home > front end >  How to group things what are not in a specific range in SQL?
How to group things what are not in a specific range in SQL?

Time:03-11

Doing revision for a SQL test I've got coming up and I'm having issues finding a query to meet one of the requirements of the questions. Heres the question:

  1. The HR department needs to find the high-salary and low-salary employees. Modify your query from (7) to display the last name and salary for all employees whose salary is not in the range 5,000 through 12,000

Here's what I've got:

SELECT last_name, salary
FROM employees
WHERE salary BETWEEN 5000 AND 12000;

When I execute the query I get all of the employees who land between those 2 values, I need the employees who land outside of the range of the 2 values. Do I need to use '<' '>'?

Any help would be greatly appreciated :)

CodePudding user response:

SELECT last_name, salary 
FROM employees 
WHERE salary NOT BETWEEN 5000 AND 12000
  • Related