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.10.1.
- Table columns
- 3.10.1.1.
- Generated table columns
- 3.10.1.2.
- Dereferenced table columns
- 3.10.1.3.
- Named table columns
- 3.10.2.
- Aliased columns
- 3.10.3.
- Cast expressions
- 3.10.4.
- Datatype coercions
- 3.10.5.
- Readonly columns (new)
- 3.10.6.
- Computed columns (new)
- 3.10.7.
- Collations
- 3.10.8.
- Arithmetic expressions
- 3.10.9.
- String concatenation
- 3.10.10.
- Case sensitivity with strings
- 3.10.11.
- General functions
- 3.10.11.1.
- CHOOSE
- 3.10.11.2.
- COALESCE
- 3.10.11.3.
- DECODE
- 3.10.11.4.
- IIF
- 3.10.11.5.
- NULLIF
- 3.10.11.6.
- NVL
- 3.10.11.7.
- NVL2
- 3.10.12.
- Numeric functions
- 3.10.12.1.
- ABS
- 3.10.12.2.
- ACOS
- 3.10.12.3.
- ASIN
- 3.10.12.4.
- ATAN
- 3.10.12.5.
- ATAN2
- 3.10.12.6.
- CEIL
- 3.10.12.7.
- COS
- 3.10.12.8.
- COSH
- 3.10.12.9.
- COT
- 3.10.12.10.
- COTH
- 3.10.12.11.
- DEG
- 3.10.12.12.
- E
- 3.10.12.13.
- EXP
- 3.10.12.14.
- FLOOR
- 3.10.12.15.
- GREATEST
- 3.10.12.16.
- LEAST
- 3.10.12.17.
- LN
- 3.10.12.18.
- LOG
- 3.10.12.19.
- LOG10
- 3.10.12.20.
- NEG
- 3.10.12.21.
- PI
- 3.10.12.22.
- POWER
- 3.10.12.23.
- RAD
- 3.10.12.24.
- RAND
- 3.10.12.25.
- ROUND
- 3.10.12.26.
- SIGN
- 3.10.12.27.
- SIN
- 3.10.12.28.
- SINH
- 3.10.12.29.
- SQRT
- 3.10.12.30.
- SQUARE
- 3.10.12.31.
- TAN
- 3.10.12.32.
- TANH
- 3.10.12.33.
- TRUNC
- 3.10.12.34.
- WIDTH_BUCKET
- 3.10.13.
- Bitwise functions
- 3.10.13.1.
- BIT_AND
- 3.10.13.2.
- BIT_COUNT
- 3.10.13.3.
- BIT_NAND
- 3.10.13.4.
- BIT_NOR
- 3.10.13.5.
- BIT_NOT
- 3.10.13.6.
- BIT_OR
- 3.10.13.7.
- BIT_XNOR
- 3.10.13.8.
- BIT_XOR
- 3.10.13.9.
- SHL
- 3.10.13.10.
- SHR
- 3.10.14.
- String functions
- 3.10.14.1.
- ASCII
- 3.10.14.2.
- BIT_LENGTH
- 3.10.14.3.
- CHR
- 3.10.14.4.
- CONCAT (|| operator)
- 3.10.14.5.
- DIGITS
- 3.10.14.6.
- LEFT
- 3.10.14.7.
- LENGTH
- 3.10.14.8.
- LOWER
- 3.10.14.9.
- LPAD
- 3.10.14.10.
- LTRIM
- 3.10.14.11.
- MD5
- 3.10.14.12.
- MID
- 3.10.14.13.
- OCTET_LENGTH
- 3.10.14.14.
- OVERLAY
- 3.10.14.15.
- POSITION
- 3.10.14.16.
- REGEXP_REPLACE
- 3.10.14.17.
- REPEAT
- 3.10.14.18.
- REPLACE
- 3.10.14.19.
- REVERSE
- 3.10.14.20.
- RIGHT
- 3.10.14.21.
- RPAD
- 3.10.14.22.
- RTRIM
- 3.10.14.23.
- SPACE
- 3.10.14.24.
- SPLIT_PART
- 3.10.14.25.
- SUBSTRING
- 3.10.14.26.
- SUBSTRING_INDEX
- 3.10.14.27.
- TO_CHAR
- 3.10.14.28.
- TO_HEX
- 3.10.14.29.
- TRANSLATE
- 3.10.14.30.
- TRIM
- 3.10.14.31.
- UPPER
- 3.10.14.32.
- UUID
- 3.10.15.
- Datetime functions
- 3.10.15.1.
- CENTURY
- 3.10.15.2.
- CURRENT_DATE
- 3.10.15.3.
- CURRENT_LOCALDATE
- 3.10.15.4.
- CURRENT_LOCALDATETIME
- 3.10.15.5.
- CURRENT_LOCALTIME
- 3.10.15.6.
- CURRENT_OFFSETDATETIME
- 3.10.15.7.
- CURRENT_OFFSETTIME
- 3.10.15.8.
- CURRENT_TIME
- 3.10.15.9.
- CURRENT_TIMESTAMP
- 3.10.15.10.
- DATE
- 3.10.15.11.
- DATEADD
- 3.10.15.12.
- DATEDIFF
- 3.10.15.13.
- DATESUB
- 3.10.15.14.
- DAY
- 3.10.15.15.
- DAY_OF_YEAR
- 3.10.15.16.
- DECADE
- 3.10.15.17.
- EPOCH
- 3.10.15.18.
- EXTRACT
- 3.10.15.19.
- HOUR
- 3.10.15.20.
- ISO_DAY_OF_WEEK
- 3.10.15.21.
- LOCALDATE
- 3.10.15.22.
- LOCALDATEADD
- 3.10.15.23.
- LOCALDATESUB
- 3.10.15.24.
- LOCALDATETIME
- 3.10.15.25.
- LOCALDATETIMEADD
- 3.10.15.26.
- LOCALDATETIMESUB
- 3.10.15.27.
- LOCALTIME
- 3.10.15.28.
- MILLENNIUM
- 3.10.15.29.
- MINUTE
- 3.10.15.30.
- MONTH
- 3.10.15.31.
- QUARTER
- 3.10.15.32.
- SECOND
- 3.10.15.33.
- TIME
- 3.10.15.34.
- TIMESTAMP
- 3.10.15.35.
- TIMESTAMPADD
- 3.10.15.36.
- TIMESTAMPSUB
- 3.10.15.37.
- TO_DATE
- 3.10.15.38.
- TO_LOCALDATE
- 3.10.15.39.
- TO_LOCALDATETIME
- 3.10.15.40.
- TO_TIMESTAMP
- 3.10.15.41.
- TRUNC
- 3.10.15.42.
- YEAR
- 3.10.16.
- ARRAY functions
- 3.10.16.1.
- ARRAY_GET
- 3.10.16.2.
- ARRAY constructor
- 3.10.16.3.
- ARRAY constructor from subquery
- 3.10.16.4.
- CARDINALITY
- 3.10.17.
- JSON functions
- 3.10.17.1.
- JSON_ARRAY
- 3.10.17.2.
- JSON_OBJECT
- 3.10.17.3.
- JSON_VALUE
- 3.10.18.
- XML functions
- 3.10.18.1.
- XMLATTRIBUTES
- 3.10.18.2.
- XMLCOMMENT
- 3.10.18.3.
- XMLCONCAT
- 3.10.18.4.
- XMLDOCUMENT
- 3.10.18.5.
- XMLELEMENT
- 3.10.18.6.
- XMLFOREST
- 3.10.18.7.
- XMLPARSE
- 3.10.18.8.
- XMLPI
- 3.10.18.9.
- XMLQUERY
- 3.10.18.10.
- XMLSERIALIZE
- 3.10.19.
- System functions
- 3.10.19.1.
- CURRENT_SCHEMA
- 3.10.19.2.
- CURRENT_USER
- 3.10.20.
- Spatial functions (new)
- 3.10.20.1.
- ST_Area (new)
- 3.10.20.2.
- ST_AsText (new)
- 3.10.20.3.
- ST_Centroid (new)
- 3.10.20.4.
- ST_Difference (new)
- 3.10.20.5.
- ST_Distance (new)
- 3.10.20.6.
- ST_EndPoint (new)
- 3.10.20.7.
- ST_ExteriorRing (new)
- 3.10.20.8.
- ST_GeometryN (new)
- 3.10.20.9.
- ST_GeometryType (new)
- 3.10.20.10.
- ST_GeomFromText (new)
- 3.10.20.11.
- ST_InteriorRingN (new)
- 3.10.20.12.
- ST_Intersection (new)
- 3.10.20.13.
- ST_Length (new)
- 3.10.20.14.
- ST_NumGeometries (new)
- 3.10.20.15.
- ST_NumInteriorRings (new)
- 3.10.20.16.
- ST_NumPoints (new)
- 3.10.20.17.
- ST_PointN (new)
- 3.10.20.18.
- ST_SRID (new)
- 3.10.20.19.
- ST_StartPoint (new)
- 3.10.20.20.
- ST_Union (new)
- 3.10.20.21.
- ST_X (new)
- 3.10.20.22.
- ST_Y (new)
- 3.10.20.23.
- ST_Z (new)
- 3.10.21.
- Aggregate functions
- 3.10.21.1.
- Grouping
- 3.10.21.2.
- Distinctness
- 3.10.21.3.
- Filtering
- 3.10.21.4.
- Ordering
- 3.10.21.5.
- Ordering WITHIN GROUP
- 3.10.21.6.
- Keeping
- 3.10.21.7.
- ANY_VALUE
- 3.10.21.8.
- ARRAY_AGG
- 3.10.21.9.
- AVG
- 3.10.21.10.
- BIT_AND_AGG (new)
- 3.10.21.11.
- BIT_OR_AGG (new)
- 3.10.21.12.
- BIT_XOR_AGG (new)
- 3.10.21.13.
- BOOL_AND
- 3.10.21.14.
- BOOL_OR
- 3.10.21.15.
- COLLECT
- 3.10.21.16.
- COUNT
- 3.10.21.17.
- CUME_DIST
- 3.10.21.18.
- DENSE_RANK
- 3.10.21.19.
- EVERY
- 3.10.21.20.
- GROUP_CONCAT
- 3.10.21.21.
- JSON_ARRAYAGG
- 3.10.21.22.
- JSON_OBJECTAGG
- 3.10.21.23.
- LISTAGG
- 3.10.21.24.
- MAX
- 3.10.21.25.
- MEDIAN
- 3.10.21.26.
- MIN
- 3.10.21.27.
- MODE
- 3.10.21.28.
- MULTISET_AGG
- 3.10.21.29.
- PERCENT_RANK
- 3.10.21.30.
- PERCENTILE_CONT
- 3.10.21.31.
- PERCENTILE_DISC
- 3.10.21.32.
- PRODUCT
- 3.10.21.33.
- RANK
- 3.10.21.34.
- SUM
- 3.10.21.35.
- XMLAGG
- 3.10.22.
- Window functions
- 3.10.22.1.
- PARTITION BY
- 3.10.22.2.
- ORDER BY
- 3.10.22.3.
- ROWS, RANGE, GROUPS (frame clause)
- 3.10.22.4.
- EXCLUDE
- 3.10.22.5.
- NULL treatment
- 3.10.22.6.
- FROM FIRST, FROM LAST
- 3.10.22.7.
- Nested aggregate functions
- 3.10.22.8.
- Window aggregation
- 3.10.22.9.
- Window ordered aggregate
- 3.10.22.10.
- ROW_NUMBER
- 3.10.22.11.
- RANK
- 3.10.22.12.
- DENSE_RANK
- 3.10.22.13.
- PERCENT_RANK
- 3.10.22.14.
- CUME_DIST
- 3.10.22.15.
- NTILE
- 3.10.22.16.
- LEAD
- 3.10.22.17.
- LAG
- 3.10.22.18.
- FIRST_VALUE
- 3.10.22.19.
- LAST_VALUE
- 3.10.22.20.
- NTH_VALUE
- 3.10.23.
- User-defined functions
- 3.10.24.
- User-defined aggregate functions
- 3.10.25.
- The CASE expression
- 3.10.26.
- Sequences and serials
- 3.10.27.
- Scalar subqueries
- 3.10.28.
- ARRAY value constructor
- 3.10.29.
- MULTISET value constructor
- 3.10.30.
- Tuples or row value expressions
- 3.10.31.
- Nested records
previous : next |
References to this page
- jOOQ as a SQL builder without code generation
- jOOQ and backwards-compatibility
- The query DSL type
- Mutability (historic)
- The WITH RECURSIVE clause
- SelectField
- Convenience methods
- ORDER BY clause
- Ordering using CASE expressions
- CREATE FUNCTION
- Scalar functions
- Variables
- 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
- SIMILAR TO predicate
- Dynamic SQL
- Plain SQL
- SQL Parser Listener
- 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!