Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10
Column expressions
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
Column expressions can be used in various SQL clauses in order to refer to one or several columns. This chapter explains how to form various types of column expressions with jOOQ. A particular type of column expression is given in the section about tuples or row value expressions, where an expression may have a degree of more than one.
Using column expressions in jOOQ
jOOQ allows you to freely create arbitrary column expressions using a fluent expression construction API. Many expressions can be formed as functions from DSL methods, other expressions can be formed based on a pre-existing column expression. For example:
// A regular table column expression Field<String> field1 = BOOK.TITLE; // A function created from the DSL Field<String> field2 = trim(BOOK.TITLE); // More complex function with advanced DSL syntax Field<String> field4 = listAgg(BOOK.TITLE) .withinGroupOrderBy(BOOK.ID.asc()) .over().partitionBy(AUTHOR.ID);
Table of contents
- 3.7.1.
- Table columns
- 3.7.1.1.
- Generated table columns
- 3.7.1.2.
- Dereferenced table columns
- 3.7.1.3.
- Named table columns
- 3.7.2.
- Aliased columns
- 3.7.3.
- Cast expressions
- 3.7.4.
- Datatype coercions
- 3.7.5.
- Collations (new)
- 3.7.6.
- Arithmetic expressions
- 3.7.7.
- String concatenation
- 3.7.8.
- Case sensitivity with strings
- 3.7.9.
- General functions
- 3.7.9.1.
- CHOOSE (new)
- 3.7.9.2.
- COALESCE
- 3.7.9.3.
- DECODE
- 3.7.9.4.
- IIF (new)
- 3.7.9.5.
- NULLIF
- 3.7.9.6.
- NVL
- 3.7.9.7.
- NVL2
- 3.7.10.
- Numeric functions
- 3.7.10.1.
- ABS
- 3.7.10.2.
- ACOS
- 3.7.10.3.
- ASIN
- 3.7.10.4.
- ATAN
- 3.7.10.5.
- ATAN2
- 3.7.10.6.
- CEIL
- 3.7.10.7.
- COS
- 3.7.10.8.
- COSH
- 3.7.10.9.
- COT
- 3.7.10.10.
- COTH
- 3.7.10.11.
- DEG
- 3.7.10.12.
- E
- 3.7.10.13.
- EXP
- 3.7.10.14.
- FLOOR
- 3.7.10.15.
- GREATEST
- 3.7.10.16.
- LEAST
- 3.7.10.17.
- LN
- 3.7.10.18.
- LOG
- 3.7.10.19.
- NEG
- 3.7.10.20.
- PI
- 3.7.10.21.
- POWER
- 3.7.10.22.
- RAD
- 3.7.10.23.
- RAND
- 3.7.10.24.
- ROUND
- 3.7.10.25.
- SIGN
- 3.7.10.26.
- SIN
- 3.7.10.27.
- SINH
- 3.7.10.28.
- SQRT
- 3.7.10.29.
- TAN
- 3.7.10.30.
- TANH
- 3.7.10.31.
- TRUNC
- 3.7.10.32.
- WIDTH_BUCKET
- 3.7.11.
- Bitwise functions
- 3.7.11.1.
- BIT_AND
- 3.7.11.2.
- BIT_COUNT
- 3.7.11.3.
- BIT_NAND
- 3.7.11.4.
- BIT_NOR
- 3.7.11.5.
- BIT_NOT
- 3.7.11.6.
- BIT_OR
- 3.7.11.7.
- BIT_XNOR
- 3.7.11.8.
- BIT_XOR
- 3.7.11.9.
- SHL
- 3.7.11.10.
- SHR
- 3.7.12.
- String functions
- 3.7.12.1.
- ASCII
- 3.7.12.2.
- BIT_LENGTH
- 3.7.12.3.
- CONCAT (|| operator)
- 3.7.12.4.
- LEFT
- 3.7.12.5.
- LENGTH
- 3.7.12.6.
- LOWER
- 3.7.12.7.
- LPAD
- 3.7.12.8.
- LTRIM
- 3.7.12.9.
- MD5
- 3.7.12.10.
- MID
- 3.7.12.11.
- OCTET_LENGTH
- 3.7.12.12.
- POSITION
- 3.7.12.13.
- REPEAT
- 3.7.12.14.
- REPLACE
- 3.7.12.15.
- REVERSE
- 3.7.12.16.
- RIGHT
- 3.7.12.17.
- RPAD
- 3.7.12.18.
- RTRIM
- 3.7.12.19.
- SPACE
- 3.7.12.20.
- SUBSTRING
- 3.7.12.21.
- TRANSLATE
- 3.7.12.22.
- TRIM
- 3.7.12.23.
- UPPER
- 3.7.13.
- Datetime functions
- 3.7.13.1.
- CURRENT_DATE
- 3.7.13.2.
- CURRENT_LOCALDATE
- 3.7.13.3.
- CURRENT_LOCALDATETIME
- 3.7.13.4.
- CURRENT_LOCALTIME
- 3.7.13.5.
- CURRENT_OFFSETDATETIME
- 3.7.13.6.
- CURRENT_OFFSETTIME
- 3.7.13.7.
- CURRENT_TIME
- 3.7.13.8.
- CURRENT_TIMESTAMP
- 3.7.13.9.
- DATE
- 3.7.13.10.
- DATEADD
- 3.7.13.11.
- DATEDIFF
- 3.7.13.12.
- DATESUB
- 3.7.13.13.
- DAY
- 3.7.13.14.
- EXTRACT
- 3.7.13.15.
- HOUR
- 3.7.13.16.
- LOCALDATE
- 3.7.13.17.
- LOCALDATEADD
- 3.7.13.18.
- LOCALDATESUB
- 3.7.13.19.
- LOCALDATETIME
- 3.7.13.20.
- LOCALDATETIMEADD (new)
- 3.7.13.21.
- LOCALDATETIMESUB (new)
- 3.7.13.22.
- LOCALTIME
- 3.7.13.23.
- MINUTE
- 3.7.13.24.
- MONTH
- 3.7.13.25.
- SECOND
- 3.7.13.26.
- TIME
- 3.7.13.27.
- TIMESTAMP
- 3.7.13.28.
- TIMESTAMPADD
- 3.7.13.29.
- TIMESTAMPSUB (new)
- 3.7.13.30.
- TO_DATE
- 3.7.13.31.
- TO_LOCALDATE
- 3.7.13.32.
- TO_LOCALDATETIME
- 3.7.13.33.
- TO_TIMESTAMP
- 3.7.13.34.
- TRUNC
- 3.7.13.35.
- YEAR
- 3.7.14.
- ARRAY functions
- 3.7.14.1.
- ARRAY constructor
- 3.7.15.
- System functions
- 3.7.15.1.
- CURRENT_SCHEMA
- 3.7.15.2.
- CURRENT_USER
- 3.7.16.
- Aggregate functions
- 3.7.16.1.
- Grouping
- 3.7.16.2.
- Distinctness
- 3.7.16.3.
- Filtering
- 3.7.16.4.
- Ordering
- 3.7.16.5.
- Ordering WITHIN GROUP
- 3.7.16.6.
- Keeping
- 3.7.16.7.
- ARRAY_AGG
- 3.7.16.8.
- AVG
- 3.7.16.9.
- BOOL_AND
- 3.7.16.10.
- BOOL_OR
- 3.7.16.11.
- COLLECT
- 3.7.16.12.
- COUNT
- 3.7.16.13.
- CUME_DIST
- 3.7.16.14.
- DENSE_RANK
- 3.7.16.15.
- EVERY
- 3.7.16.16.
- GROUP_CONCAT
- 3.7.16.17.
- LISTAGG
- 3.7.16.18.
- MAX
- 3.7.16.19.
- MEDIAN
- 3.7.16.20.
- MIN
- 3.7.16.21.
- MODE
- 3.7.16.22.
- PERCENT_RANK
- 3.7.16.23.
- PERCENTILE_CONT
- 3.7.16.24.
- PERCENTILE_DISC
- 3.7.16.25.
- PRODUCT
- 3.7.16.26.
- RANK
- 3.7.16.27.
- SUM
- 3.7.17.
- Window functions
- 3.7.17.1.
- PARTITION BY
- 3.7.17.2.
- ORDER BY
- 3.7.17.3.
- ROWS, RANGE, GROUPS (frame clause)
- 3.7.17.4.
- EXCLUDE
- 3.7.17.5.
- NULL treatment
- 3.7.17.6.
- FROM FIRST, FROM LAST
- 3.7.17.7.
- Nested aggregate functions
- 3.7.17.8.
- Window aggregation
- 3.7.17.9.
- Window ordered aggregate
- 3.7.17.10.
- ROW_NUMBER
- 3.7.17.11.
- RANK
- 3.7.17.12.
- DENSE_RANK
- 3.7.17.13.
- PERCENT_RANK
- 3.7.17.14.
- CUME_DIST
- 3.7.17.15.
- NTILE
- 3.7.17.16.
- LEAD
- 3.7.17.17.
- LAG
- 3.7.17.18.
- FIRST_VALUE
- 3.7.17.19.
- LAST_VALUE
- 3.7.17.20.
- NTH_VALUE
- 3.7.18.
- User-defined functions
- 3.7.19.
- User-defined aggregate functions
- 3.7.20.
- The CASE expression
- 3.7.21.
- Sequences and serials
- 3.7.22.
- Scalar subqueries
- 3.7.23.
- Tuples or row value expressions
previous : next |
References to this page
- jOOQ as a SQL builder without code generation
- jOOQ and backwards-compatibility
- The query DSL type
- jOOQ's DSL and model API
- The WITH RECURSIVE clause
- Convenience methods
- ORDER BY clause
- Ordering using CASE expressions
- Derived tables
- Table columns
- Generated table columns
- User-defined functions
- The CASE expression
- Scalar subqueries
- Conditional expressions
- Condition building
- Comparison predicate (degree > 1)
- LIKE predicate
- NULL predicate
- Dynamic SQL
- Plain SQL
- Names and identifiers
- Custom data type bindings
- Custom data type conversion
- Stored procedures and functions
- BOOLEAN data type
Feedback
Do you have any feedback about this page? We'd love to hear it!