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

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

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

4.11.1.
Table columns
4.11.1.1.
Generated table columns
4.11.1.2.
Dereferenced table columns
4.11.1.3.
Named table columns
4.11.2.
Aliased columns
4.11.3.
Cast expressions
4.11.4.
Cast expressions (with TRY_CAST)
4.11.5.
Datatype coercions
4.11.6.
Hidden columns (new)
4.11.7.
Readonly columns
4.11.8.
Computed columns
4.11.9.
Collations
4.11.10.
Arithmetic expressions
4.11.11.
String concatenation
4.11.12.
Case sensitivity with strings
4.11.13.
General functions
4.11.13.1.
CHOOSE
4.11.13.2.
COALESCE
4.11.13.3.
DECODE
4.11.13.4.
IIF
4.11.13.5.
NULLIF
4.11.13.6.
NVL
4.11.13.7.
NVL2
4.11.14.
Numeric functions
4.11.14.1.
ABS
4.11.14.2.
ACOS
4.11.14.3.
ASIN
4.11.14.4.
ATAN
4.11.14.5.
ATAN2
4.11.14.6.
CEIL
4.11.14.7.
COS
4.11.14.8.
COSH
4.11.14.9.
COT
4.11.14.10.
COTH
4.11.14.11.
DEG
4.11.14.12.
E
4.11.14.13.
EXP
4.11.14.14.
FLOOR
4.11.14.15.
GREATEST
4.11.14.16.
LEAST
4.11.14.17.
LN
4.11.14.18.
LOG
4.11.14.19.
LOG10
4.11.14.20.
NEG
4.11.14.21.
PI
4.11.14.22.
POWER
4.11.14.23.
RAD
4.11.14.24.
RAND
4.11.14.25.
ROUND
4.11.14.26.
SIGN
4.11.14.27.
SIN
4.11.14.28.
SINH
4.11.14.29.
SQRT
4.11.14.30.
SQUARE
4.11.14.31.
TAN
4.11.14.32.
TANH
4.11.14.33.
TRUNC
4.11.14.34.
WIDTH_BUCKET
4.11.15.
Bitwise functions
4.11.15.1.
BIT_AND
4.11.15.2.
BIT_COUNT
4.11.15.3.
BIT_GET
4.11.15.4.
BIT_NAND
4.11.15.5.
BIT_NOR
4.11.15.6.
BIT_NOT
4.11.15.7.
BIT_OR
4.11.15.8.
BIT_SET
4.11.15.9.
BIT_XNOR
4.11.15.10.
BIT_XOR
4.11.15.11.
SHL
4.11.15.12.
SHR
4.11.16.
String functions
4.11.16.1.
ASCII
4.11.16.2.
BIN_TO_UUID (new)
4.11.16.3.
BIT_LENGTH
4.11.16.4.
CHR
4.11.16.5.
CONCAT (|| operator)
4.11.16.6.
DIGITS
4.11.16.7.
LEFT
4.11.16.8.
LENGTH
4.11.16.9.
LOWER
4.11.16.10.
LPAD
4.11.16.11.
LTRIM
4.11.16.12.
MD5
4.11.16.13.
MID
4.11.16.14.
OCTET_LENGTH
4.11.16.15.
OVERLAY
4.11.16.16.
POSITION
4.11.16.17.
REGEXP_REPLACE
4.11.16.18.
REPEAT
4.11.16.19.
REPLACE
4.11.16.20.
REVERSE
4.11.16.21.
RIGHT
4.11.16.22.
RPAD
4.11.16.23.
RTRIM
4.11.16.24.
SPACE
4.11.16.25.
SPLIT_PART
4.11.16.26.
SUBSTRING
4.11.16.27.
SUBSTRING_INDEX
4.11.16.28.
TO_CHAR
4.11.16.29.
TO_HEX
4.11.16.30.
TRANSLATE
4.11.16.31.
TRIM
4.11.16.32.
UPPER
4.11.16.33.
UUID
4.11.16.34.
UUID_TO_BIN (new)
4.11.17.
Binary functions (new)
4.11.17.1.
BIT_LENGTH (binary) (new)
4.11.17.2.
CONCAT (binary, || operator) (new)
4.11.17.3.
LENGTH (binary) (new)
4.11.17.4.
LTRIM (binary) (new)
4.11.17.5.
MD5 (binary) (new)
4.11.17.6.
OCTET_LENGTH (binary) (new)
4.11.17.7.
OVERLAY (binary) (new)
4.11.17.8.
POSITION (binary) (new)
4.11.17.9.
RTRIM (binary) (new)
4.11.17.10.
TRIM (binary) (new)
4.11.18.
Datetime functions
4.11.18.1.
CENTURY
4.11.18.2.
CURRENT_DATE
4.11.18.3.
CURRENT_LOCALDATE
4.11.18.4.
CURRENT_LOCALDATETIME
4.11.18.5.
CURRENT_LOCALTIME
4.11.18.6.
CURRENT_OFFSETDATETIME
4.11.18.7.
CURRENT_OFFSETTIME
4.11.18.8.
CURRENT_TIME
4.11.18.9.
CURRENT_TIMESTAMP
4.11.18.10.
DATE
4.11.18.11.
DATEADD
4.11.18.12.
DATEDIFF
4.11.18.13.
DATESUB
4.11.18.14.
DAY
4.11.18.15.
DAY_OF_YEAR
4.11.18.16.
DECADE
4.11.18.17.
EPOCH
4.11.18.18.
EXTRACT
4.11.18.19.
HOUR
4.11.18.20.
ISO_DAY_OF_WEEK
4.11.18.21.
LOCALDATE
4.11.18.22.
LOCALDATEADD
4.11.18.23.
LOCALDATESUB
4.11.18.24.
LOCALDATETIME
4.11.18.25.
LOCALDATETIMEADD
4.11.18.26.
LOCALDATETIMESUB
4.11.18.27.
LOCALTIME
4.11.18.28.
MILLENNIUM
4.11.18.29.
MINUTE
4.11.18.30.
MONTH
4.11.18.31.
QUARTER
4.11.18.32.
SECOND
4.11.18.33.
TIME
4.11.18.34.
TIMESTAMP
4.11.18.35.
TIMESTAMPADD
4.11.18.36.
TIMESTAMPSUB
4.11.18.37.
TO_DATE
4.11.18.38.
TO_LOCALDATE
4.11.18.39.
TO_LOCALDATETIME
4.11.18.40.
TO_TIMESTAMP
4.11.18.41.
TRUNC
4.11.18.42.
YEAR
4.11.19.
ARRAY functions
4.11.19.1.
ARRAY_ALL_MATCH (new)
4.11.19.2.
ARRAY_ANY_MATCH (new)
4.11.19.3.
ARRAY_APPEND (|| operator)
4.11.19.4.
ARRAY_CONCAT (|| operator)
4.11.19.5.
ARRAY_FILTER (new)
4.11.19.6.
ARRAY_GET
4.11.19.7.
ARRAY_MAP (new)
4.11.19.8.
ARRAY_NONE_MATCH (new)
4.11.19.9.
ARRAY_OVERLAP
4.11.19.10.
ARRAY_PREPEND (|| operator)
4.11.19.11.
ARRAY_REMOVE
4.11.19.12.
ARRAY_REPLACE
4.11.19.13.
ARRAY constructor
4.11.19.14.
ARRAY constructor from subquery
4.11.19.15.
CARDINALITY
4.11.20.
JSON functions
4.11.20.1.
JSON_ARRAY
4.11.20.2.
JSON_ARRAY_LENGTH (new)
4.11.20.3.
JSON_INSERT function
4.11.20.4.
JSON_KEYS
4.11.20.5.
JSON_OBJECT
4.11.20.6.
JSON_REMOVE function
4.11.20.7.
JSON_REPLACE function
4.11.20.8.
JSON_SET function
4.11.20.9.
JSON_VALUE
4.11.20.10.
JSON array element access with -> or ->>
4.11.20.11.
JSON object attribute access with -> or ->>
4.11.21.
XML functions
4.11.21.1.
XMLATTRIBUTES
4.11.21.2.
XMLCOMMENT
4.11.21.3.
XMLCONCAT
4.11.21.4.
XMLDOCUMENT
4.11.21.5.
XMLELEMENT
4.11.21.6.
XMLFOREST
4.11.21.7.
XMLPARSE
4.11.21.8.
XMLPI
4.11.21.9.
XMLQUERY
4.11.21.10.
XMLSERIALIZE
4.11.22.
System functions
4.11.22.1.
CURRENT_SCHEMA
4.11.22.2.
CURRENT_USER
4.11.23.
Spatial functions
4.11.23.1.
ST_Area
4.11.23.2.
ST_AsText
4.11.23.3.
ST_Centroid
4.11.23.4.
ST_Difference
4.11.23.5.
ST_Distance
4.11.23.6.
ST_EndPoint
4.11.23.7.
ST_ExteriorRing
4.11.23.8.
ST_GeometryN
4.11.23.9.
ST_GeometryType
4.11.23.10.
ST_GeomFromText
4.11.23.11.
ST_InteriorRingN
4.11.23.12.
ST_Intersection
4.11.23.13.
ST_Length
4.11.23.14.
ST_NumGeometries
4.11.23.15.
ST_NumInteriorRings
4.11.23.16.
ST_NumPoints
4.11.23.17.
ST_PointN
4.11.23.18.
ST_SRID
4.11.23.19.
ST_StartPoint
4.11.23.20.
ST_Union
4.11.23.21.
ST_X
4.11.23.22.
ST_Y
4.11.23.23.
ST_Z
4.11.24.
Aggregate functions
4.11.24.1.
Grouping
4.11.24.2.
Distinctness
4.11.24.3.
Filtering
4.11.24.4.
Ordering
4.11.24.5.
Ordering WITHIN GROUP
4.11.24.6.
Keeping
4.11.24.7.
ANY_VALUE
4.11.24.8.
ARRAY_AGG
4.11.24.9.
AVG
4.11.24.10.
BIT_AND_AGG
4.11.24.11.
BIT_NAND_AGG
4.11.24.12.
BIT_NOR_AGG
4.11.24.13.
BIT_OR_AGG
4.11.24.14.
BIT_XOR_AGG
4.11.24.15.
BIT_XNOR_AGG
4.11.24.16.
BOOL_AND
4.11.24.17.
BOOL_OR
4.11.24.18.
COLLECT
4.11.24.19.
COUNT
4.11.24.20.
CUME_DIST
4.11.24.21.
DENSE_RANK
4.11.24.22.
EVERY
4.11.24.23.
GROUP_CONCAT
4.11.24.24.
JSON_ARRAYAGG
4.11.24.25.
JSON_OBJECTAGG
4.11.24.26.
LISTAGG
4.11.24.27.
MAX
4.11.24.28.
MEDIAN
4.11.24.29.
MIN
4.11.24.30.
MODE
4.11.24.31.
MULTISET_AGG
4.11.24.32.
PERCENT_RANK
4.11.24.33.
PERCENTILE_CONT
4.11.24.34.
PERCENTILE_DISC
4.11.24.35.
PRODUCT
4.11.24.36.
RANK
4.11.24.37.
SUM
4.11.24.38.
XMLAGG
4.11.25.
Window functions
4.11.25.1.
PARTITION BY
4.11.25.2.
ORDER BY
4.11.25.3.
ROWS, RANGE, GROUPS (frame clause)
4.11.25.4.
EXCLUDE
4.11.25.5.
NULL treatment
4.11.25.6.
FROM FIRST, FROM LAST
4.11.25.7.
Nested aggregate functions
4.11.25.8.
Window aggregation
4.11.25.9.
Window ordered aggregate
4.11.25.10.
ROW_NUMBER
4.11.25.11.
RANK
4.11.25.12.
DENSE_RANK
4.11.25.13.
PERCENT_RANK
4.11.25.14.
CUME_DIST
4.11.25.15.
NTILE
4.11.25.16.
LEAD
4.11.25.17.
LAG
4.11.25.18.
FIRST_VALUE
4.11.25.19.
LAST_VALUE
4.11.25.20.
NTH_VALUE
4.11.26.
Grouping functions
4.11.27.
User-defined functions
4.11.28.
User-defined aggregate functions
4.11.29.
User-defined type attribute paths
4.11.30.
The CASE expression
4.11.31.
Sequences and serials
4.11.32.
Scalar subqueries
4.11.33.
ARRAY value constructor
4.11.34.
MULTISET value constructor
4.11.35.
Tuples or row value expressions
4.11.36.
Nested records

previous : next

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo