Available in versions: Dev (3.19) | Latest (3.18) | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9

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.7.1.
Table columns
4.7.1.1.
Generated table columns
4.7.1.2.
Dereferenced table columns
4.7.1.3.
Named table columns
4.7.2.
Aliased columns
4.7.3.
Cast expressions
4.7.4.
Datatype coercions
4.7.5.
Arithmetic expressions
4.7.6.
String concatenation
4.7.7.
Case sensitivity with strings
4.7.8.
General functions
4.7.8.1.
COALESCE
4.7.8.2.
DECODE
4.7.8.3.
NULLIF
4.7.8.4.
NVL
4.7.8.5.
NVL2
4.7.9.
Numeric functions
4.7.9.1.
ABS
4.7.9.2.
ACOS
4.7.9.3.
ASIN
4.7.9.4.
ATAN
4.7.9.5.
ATAN2
4.7.9.6.
CEIL
4.7.9.7.
COS
4.7.9.8.
COSH
4.7.9.9.
COT
4.7.9.10.
COTH
4.7.9.11.
DEG
4.7.9.12.
E
4.7.9.13.
EXP
4.7.9.14.
FLOOR
4.7.9.15.
GREATEST
4.7.9.16.
LEAST
4.7.9.17.
LN
4.7.9.18.
LOG
4.7.9.19.
NEG
4.7.9.20.
PI
4.7.9.21.
POWER
4.7.9.22.
RAD
4.7.9.23.
RAND
4.7.9.24.
ROUND
4.7.9.25.
SIGN
4.7.9.26.
SIN
4.7.9.27.
SINH
4.7.9.28.
SQRT
4.7.9.29.
TAN
4.7.9.30.
TANH
4.7.9.31.
TRUNC
4.7.10.
Bitwise functions
4.7.10.1.
BIT_AND
4.7.10.2.
BIT_COUNT
4.7.10.3.
BIT_NAND
4.7.10.4.
BIT_NOR
4.7.10.5.
BIT_NOT
4.7.10.6.
BIT_OR
4.7.10.7.
BIT_XNOR
4.7.10.8.
BIT_XOR
4.7.10.9.
SHL
4.7.10.10.
SHR
4.7.11.
String functions
4.7.11.1.
ASCII
4.7.11.2.
CONCAT
4.7.11.3.
LEFT
4.7.11.4.
LENGTH
4.7.11.5.
LOWER
4.7.11.6.
LPAD
4.7.11.7.
LTRIM
4.7.11.8.
MD5
4.7.11.9.
MID
4.7.11.10.
POSITION
4.7.11.11.
REPEAT
4.7.11.12.
REPLACE
4.7.11.13.
REVERSE
4.7.11.14.
RIGHT
4.7.11.15.
RPAD
4.7.11.16.
RTRIM
4.7.11.17.
SPACE
4.7.11.18.
SUBSTRING
4.7.11.19.
TRANSLATE
4.7.11.20.
TRIM
4.7.11.21.
UPPER
4.7.12.
Datetime functions
4.7.12.1.
CURRENT_DATE
4.7.12.2.
CURRENT_LOCALDATE
4.7.12.3.
CURRENT_LOCALDATETIME
4.7.12.4.
CURRENT_LOCALTIME
4.7.12.5.
CURRENT_OFFSETDATETIME
4.7.12.6.
CURRENT_OFFSETTIME
4.7.12.7.
CURRENT_TIME
4.7.12.8.
CURRENT_TIMESTAMP
4.7.12.9.
DATE
4.7.12.10.
DATEADD
4.7.12.11.
DATEDIFF
4.7.12.12.
DATESUB
4.7.12.13.
DAY
4.7.12.14.
EXTRACT
4.7.12.15.
HOUR
4.7.12.16.
LOCALDATE
4.7.12.17.
LOCALDATETIME
4.7.12.18.
LOCALTIME
4.7.12.19.
MINUTE
4.7.12.20.
MONTH
4.7.12.21.
SECOND
4.7.12.22.
TIME
4.7.12.23.
TIMESTAMP
4.7.12.24.
TIMESTAMPADD
4.7.12.25.
TO_DATE
4.7.12.26.
TO_LOCALDATE
4.7.12.27.
TO_LOCALDATETIME
4.7.12.28.
TO_TIMESTAMP
4.7.12.29.
TRUNC
4.7.12.30.
YEAR
4.7.13.
ARRAY functions
4.7.13.1.
ARRAY constructor
4.7.14.
System functions
4.7.14.1.
CURRENT_SCHEMA
4.7.14.2.
CURRENT_USER
4.7.15.
Aggregate functions
4.7.15.1.
Grouping
4.7.15.2.
Distinctness
4.7.15.3.
Filtering
4.7.15.4.
Ordering
4.7.15.5.
Ordering WITHIN GROUP
4.7.15.6.
Keeping
4.7.15.7.
ARRAY_AGG
4.7.15.8.
AVG
4.7.15.9.
BOOL_AND
4.7.15.10.
BOOL_OR
4.7.15.11.
COLLECT
4.7.15.12.
COUNT
4.7.15.13.
CUME_DIST
4.7.15.14.
DENSE_RANK
4.7.15.15.
EVERY
4.7.15.16.
GROUP_CONCAT
4.7.15.17.
LISTAGG
4.7.15.18.
MAX
4.7.15.19.
MEDIAN
4.7.15.20.
MIN
4.7.15.21.
MODE
4.7.15.22.
PERCENT_RANK
4.7.15.23.
PERCENTILE_CONT
4.7.15.24.
PERCENTILE_DISC
4.7.15.25.
PRODUCT
4.7.15.26.
RANK
4.7.15.27.
SUM
4.7.16.
Window functions
4.7.16.1.
PARTITION BY
4.7.16.2.
ORDER BY
4.7.16.3.
ROWS, RANGE, GROUPS (frame clause)
4.7.16.4.
EXCLUDE
4.7.16.5.
NULL treatment
4.7.16.6.
FROM FIRST, FROM LAST
4.7.16.7.
Nested aggregate functions
4.7.16.8.
Window aggregation
4.7.16.9.
Window ordered aggregate
4.7.16.10.
ROW_NUMBER
4.7.16.11.
RANK
4.7.16.12.
DENSE_RANK
4.7.16.13.
PERCENT_RANK
4.7.16.14.
CUME_DIST
4.7.16.15.
NTILE
4.7.16.16.
LEAD
4.7.16.17.
LAG
4.7.16.18.
FIRST_VALUE
4.7.16.19.
LAST_VALUE
4.7.16.20.
NTH_VALUE
4.7.17.
Grouping functions
4.7.18.
User-defined functions
4.7.19.
User-defined aggregate functions
4.7.20.
The CASE expression
4.7.21.
Sequences and serials
4.7.22.
Scalar subqueries
4.7.23.
Tuples or row value expressions

previous : next

Feedback

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

The jOOQ Logo