Write an SQL query to find an employee whose salary is equal to or greater than 10000

Write an SQL query to find an employee whose salary is equal to or greater than 10000

SQL stands for Structured Query Language. It is used to fetch the data from Relational databases or tables with the help of some queries. 

In SQL, to find an employee whose salary is equal to or greater than 10000. We have to use the WHERE clause. In this blog, we will learn how to perform this task in detail.

Table of Contents:

SQL query to find an employee whose salary is equal to or greater than 10000.

To find the employee whose salary is equal to or greater than 10000 in SQL, we have to use the SELECT statement and WHERE clause.

Example: suppose we have a table of Employees,  and we have to find the employees having salaries greater than 10000.

Emp_id Name Department Salary
101 Alice HR 12000
102 Bob IT 8000
103 Charlie Finance 15000
104 David IT 9500
105 Emma Sales 11000

Query:

SELECT * FROM employees  
WHERE salary >= 10000;

Output:

Emp_id Name Department Salary
101 Alice HR 12000
103 Charlie Finance 15000
105 Emma Sales 11000

Explanation: Here we have used the SELECT statement to select the rows from the employee table, and the WHERE clause is used to filter the rows based on the condition (salary >= 10000).

Filters to the Employee table

We can also add some more features to the table according to our needs:

Example 1: Filter the row having dep=’IT’ and salary is greater than 5000.

Here, we want to print the rows having department IT and salary greater than 5000. let’s have a look at below Query:

Query:

SELECT * FROM employees  
WHERE salary >= 5000 AND department = 'IT';

Output:

Emp_id Name Department Salary
102 Bob IT 8000
104 David IT 9500

Example 2: Find the Employee having a salary greater than 10000 and give the output in a sorted way.

Here, we have to print the rows in a sorted way having a salary greater than 10000.

Query:

SELECT * FROM employees  
WHERE salary >= 10000
ORDER BY salary DESC;

Output:

Emp_idNameDepartmentSalary
103CharlieFinance15000
101AliceHR12000
105EmmaSales11000

Explanation: We have used the ORDER BY command here, which is used to sort the data, we have sorted the data according to salary by the command, ORDER BY salary DESC.

Example 3: Find the Employee whose department is either of them (‘HR’ and ‘Sales’)

Query:

SELECT * FROM employees
WHERE department IN ('HR', 'Sales');

Output:

Emp_idNameDepartmentSalary
101AliceHR12000
105EmmaSales11000

Explanation: Here we have used the SQL IN operator to find whether the employee belongs to the HR or the sales department.

Get 100% Hike!

Master Most in Demand Skills Now!

Conclusion

SQL is used to retrieve data from tables and displaying into our codes. Here in this article, we have learned how we can find an employee with a salary greater than 10000, and we have also applied some more filters to that output. If you want to excel in your career in SQL, you should refer to our SQL Course for a better understanding.

FAQs

How do you write greater than or equal to in SQL query?

In SQL, to writes greater than or equal to, we use the >= operator.

What is the SQL SELECT command?

The SELECT command is used to retrieve data from a database

How to use WHERE in SQL?

The WHERE clause in SQL is used to filter records that meet a certain condition