Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
SELECT HOUR('2001-02-03 04:05:06') FROM Employee

Example

Code Block
SELECT MINUTE('2001-02-03 04:08:06') FROM Employee 

Example

Code Block
SELECT MONTH('2001-05-03') FROM Employee 

Example

Code Block
SELECT YEAR('2045-02-03') FROM Employee

...

More Functions (New in 17.0)

...

Converts a value to another data type.

Example

Code Block
SELECT CAST(ID AS INT) FROM Employee

Back to top

COALESCE

Returns the first value that is not null.

Example

Code Block
SELECT COALESCE(ID, Age, Salary) FROM Employee

Back to top

GREATEST

Returns the largest value that is not NULL, or NULL if all values are NULL.

Example

Code Block
SELECT GREATEST(1, 2, 3) FROM Employee

...

LEAST

Returns the smallest value that is not NULL, or NULL if all values are NULL.

Example

Code Block
SELECT LEAST(1,2,3) FROM Employee

...

IFNULL

IFNULL(a, b)

Returns the value of 'a' if it is not null, otherwise 'b'.

Example

Code Block
SELECT SUM (IFNULL(Salary,100)) FROM Employee

Back to top

NULLIF

NULLIF(a, b)

Returns NULL if 'a' is equals to 'b', otherwise 'a'.

Example

Code Block
SELECT Fname,NULLIF(E_id ,Salary) FROM Employee

Back to top

NVL2

NVL2(testValue, a, b)

If the test value is null, then 'b' is returned. Otherwise, 'a' is returned. The data type of the returned value is the data type of 'a' if this is a text type.

Example

Code Block
SELECT NVL2(ID, 'not null', 'null') FROM Employee

Back to top

ROWNUM

Returns the number of the current row.

Example

Code Block
SELECT ROWNUM(), * FROM Employee