Skip to main content
Log inGet a demo
Back to SQL Dictionary
Comparison operators

SQL Greater Than

What is the SQL Greater Than Operator?

The SQL "Greater Than" operator, denoted as ">", is used to compare values in a database table and retrieve rows where a specific column's value is greater than a given criteria.

When you would use it

You would use the "Greater Than" operator when you want to filter and retrieve data from a database table based on values that are greater than a particular value or expression. This is useful when you need to extract data that meets specific conditions related to higher values.

Syntax

The basic syntax for using the "Greater Than" operator in an SQL query is as follows:

SELECT column1, column2
FROM table_name
WHERE column_name > value;
  • SELECT: Specifies the columns you want to retrieve.
  • FROM: Specifies the table from which you want to retrieve data.
  • WHERE: Specifies the condition for filtering rows.
  • column_name: The name of the column you want to compare.
  • value: The value or expression you want to compare the column with.

Parameter values

  • column_name: The name of the column you want to filter.
  • value: The value or expression you want to compare against.

Example query

Assume we have a table named "products" with columns: "product_id," "product_name," and "price." Here's an example query using the "Greater Than" operator:

SELECT product_name, price
FROM products
WHERE price > 20.00;

In this query, we're retrieving the product names and prices of products whose price is greater than $20.00.

Example table response

Suppose the "products" table has the following data:

product_idproduct_nameprice
1Widget A19.99
2Widget B22.50
3Widget C25.00
4Widget D18.95

The query would return:

product_nameprice
Widget B22.50
Widget C25.00

Use cases

The "Greater Than" operator is commonly used in various scenarios, including:

  1. Finding data that exceeds specific numerical thresholds, such as searching for high-value transactions or products.
  2. Extracting data that is newer than a given date or timestamp.
  3. Filtering records based on numeric comparisons in aggregate functions.

SQL languages this is available for

The "Greater Than" operator is a standard feature supported by all major SQL database management systems (DBMS) and SQL-based languages, including but not limited to:

  • MySQL
  • PostgreSQL
  • Oracle Database
  • Microsoft SQL Server
  • SQLite
  • IBM Db2

In summary, the "Greater Than" operator is a fundamental tool for filtering and retrieving data based on numerical comparisons in SQL databases, and it is available in all major SQL database systems. It allows you to specify conditions for extracting rows with values greater than your criteria.

Related

SQL Not Equal To

SQL Less Than

SQL Greater Than or Equal To

Share

Book a demo

Work email

Start syncing data in minutes

Check out this 5 minute interactive demo to learn how you can sync customer data to any business tool.

Hightouch Audiences user interface.

Activate your data in less than 5 minutes