DEV Community

Judy
Judy

Posted on

SQL, get median of all columns in each row #eg21

In PostgreSQL database, table T has multiple numeric columns:

Image description
We want to find the median of all column values in each row. Below is the expected result:

Image description
Write the following SPL code:

Image description
new()function creates a new two-dimensional table; ~ represents the current record; array() function converts field values of a record to a sequence.

Top comments (1)

Collapse
 
esproc_spl profile image
Judy

SPL open source address:github.com/SPLWare/esProc/stargazers