SQL GREATER THAN
Anonymous contributor
Published Aug 6, 2024
Contribute to Docs
The GREATER THAN (>) operator selects rows with values strictly greater than a given condition. It can be applied to numeric values and dates. This operator can be combined with the equality operator = as a GREATER THAN OR EQUAL TO (>=) to be inclusive of the condition.
Syntax
SELECT *
FROM table
WHERE column > condition;
The column must exist in the table and be either a numeric or date-type column. The values in column will then be compared to the condition.
Example 1
The table Coffee tracks the number of cups ordered. Return rows where the column cups has a value strictly greater than (>) 3.
CREATE TABLE Coffee (name varchar(255),drink varchar(255),order_date date,cups int);SELECT *FROM CoffeeWHERE cups > 3;
Example 2
Using the same table above, we make a comparison on the date column. Return rows where order_date is greater than or equal to (>=) 2020-01-01.
SELECT *FROM CoffeeWHERE order_date >= '2020-01-01';
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SQL on Codecademy
- Learn to analyze data with SQL and prepare for technical interviews.
- Includes 9 Courses
- With Certificate
- Beginner Friendly.17 hours
- In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.
- Beginner Friendly.5 hours