Returns NULL if the first argument is NULL; otherwise, returns the second argument.
Note that REGR_VALX is a NULL-preserving function, while the more commonly-used NVL is a NULL-replacing function.
Syntax¶ Arguments¶y
:
An expression that evaluates to type DOUBLE
or that can be cast to DOUBLE
.
x
:
An expression that evaluates to type DOUBLE
or that can be cast to DOUBLE
.
Important
Note the order of the arguments; y precedes x.
Returns¶Returns a value of type DOUBLE
.
Basic example:
SELECT REGR_VALX(NULL, 10), REGR_VALX(1, NULL), REGR_VALX(1, 10); +---------------------+--------------------+------------------+ | REGR_VALX(NULL, 10) | REGR_VALX(1, NULL) | REGR_VALX(1, 10) | |---------------------+--------------------+------------------| | NULL | NULL | 10 | +---------------------+--------------------+------------------+Copy
This example is similar to the preceding example, but shows more clearly that the convention is to pass the Y
value first. It also shows the difference between REGR_VALX and REGR_VALY:
CREATE TABLE xy (col_x DOUBLE, col_y DOUBLE); INSERT INTO xy (col_x, col_y) VALUES (1.0, 2.0), (3.0, NULL), (NULL, 6.0);Copy
SELECT col_y, col_x, REGR_VALX(col_y, col_x), REGR_VALY(col_y, col_x) FROM xy; +-------+-------+-------------------------+-------------------------+ | COL_Y | COL_X | REGR_VALX(COL_Y, COL_X) | REGR_VALY(COL_Y, COL_X) | |-------+-------+-------------------------+-------------------------| | 2 | 1 | 1 | 2 | | NULL | 3 | NULL | NULL | | 6 | NULL | NULL | NULL | +-------+-------+-------------------------+-------------------------+Copy
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4