Threshold filtering
Filter records above a threshold such as users older than 18 or products priced over 100.
Drizzle ORM · Function
gt builds a greater-than filter for Drizzle queries. It compares a column or SQL expression with a value or another expression and is typically passed to where.
gt creates a filter that compares a column or SQL expression with a value or another column and keeps rows where the left side is greater. Use it inside a query's where clause; Drizzle emits the SQL > comparison and parameterizes supplied values.
gt(left, right)| Name | Type | Description |
|---|---|---|
left | SQL expression | Left-hand column or SQL expression to compare. |
right | value or SQL expression | Value or column/expression that the left operand must exceed. |
A SQL boolean condition for use in query filters.
drizzle-orm package.> predicate in the generated statement.gt are parameterized automatically, so use the operator instead of interpolating runtime values into SQL.import { gt } from "drizzle-orm";
const rows = await db
.select()
.from(users)
.where(gt(users.age, 18));Selects users whose age is greater than 18.
Filter records above a threshold such as users older than 18 or products priced over 100.
Compare two fields and retain rows where one column exceeds another.
Combine a lower bound with lt to select values inside an exclusive range.
gt do?gt is Drizzle ORM's greater-than filter operator. It can compare a column with a value, producing a SQL > predicate in a where clause.
Follow-up: How can it compare two columns? Pass both column expressions, such as gt(table.column1, table.column2), which produces a column-to-column > comparison.
gt in a query?Import gt from drizzle-orm and pass the left-hand expression plus the value or expression to compare against. For example, where(gt(table.column, 5)) selects rows whose column exceeds 5.
Follow-up: How is the runtime value handled? Drizzle parameterizes values supplied to filter operators automatically.
gt express a range?gt can be combined with other filter operators through logical operators such as and. A range can therefore be expressed with and(gt(table.column, 5), lt(table.column, 7)).
Follow-up: What SQL shape does that produce? Drizzle emits a parenthesized conjunction containing the greater-than and less-than predicates.
gteltlteeqneandorsql