ABS CEIL FLOOR functions in SQL

For Complete YouTube Video: Click Here

In this class, we will understand ABS CEIL FLOOR Functions in SQL.

We have already discussed LENGTH SUBSTR and INSTR functions in SQL.

ABS CEIL FLOOR Functions in SQL

Number Functions in SQL

The ABS CEIL FLOOR functions in SQL are number functions.

The number functions are divided into two.

  1. Single value functions
  2. Aggregate value functions

Single Value Functions

The functions applied on only one value are called single-value functions.

There is a wide variety of single-value functions in SQL.

 In this class, we will cover ABS CEIL FLOOR functions.

Aggregate Value Functions

The functions applied on the list of values are called aggregate-value functions. Ex: sum, average, etc.

ABS: Absolute Value is the measure of the magnitude of some value.

To understand these functions consider the table shown below.

ABS CEIL FLOOR functions in SQL 1
ABS CEIL FLOOR functions in SQL 1

The ABS will produce the magnitude of a number, not the sign of the number.

The query with ABS and the output of the ‘query’ are as shown below.

SELECT ABS(value) FROM numbers;

ABS CEIL FLOOR functions in SQL 2
ABS CEIL FLOOR functions in SQL 2

Ceil: Ceil produces the smallest whole number that is greater than or equal to the specified value.

For example, consider the 1.3, 1.3 is between 1 and 2.

The numbers whose value is more than 1.3 are 2, 3, 4, 5, and so on.

The smallest among those is 2.

The CEIL will produce 2.

The query with CEIL and the output of the ‘query’ is as shown below.

SELECT CEIL(value) FROM numbers;

ABS CEIL FLOOR functions in SQL 3
ABS CEIL FLOOR functions in SQL 3

Floor: Floor produces the ‘largest’ whole number less than or equal to the specified value.

For example, consider the 1.3, 1.3 is between 1 and 2.

The numbers whose value is less than 1.3 are 1, 0, -1, -2, and so on.

The largest among those is 1.

The FLOOR will produce 1.

The query with FLOOR and the output of the ‘query’ is as shown below.

SELECT FLOOR(value) FROM numbers;

ABS CEIL FLOOR functions in SQL 4
ABS CEIL FLOOR functions in SQL 4