Hello, dear friends.
So one of the important functions of Ezekial Server is math functions, right?
So in this section, we're going to talk about and we're going to learn in greater detail the math functions.
So I want to start with a B.S., which is a function that comes from the absolute key word, so the
ABS function returns the absolute value of a number.
This function will take only one parameter and it must be a number.
So let's build the query and set minus 200 and two.
And the ABC function will remove the minus from the number and then return the result as a positive
number.
Executed.
And here is the absolute of this No.
The average function.
The average function is in aggregate that returns the average value of an expression.
An aggregate function performs a calculation, one or more values and returns a single value.
So the aggregate function is often used with the group by Claw's and the having clause of the select
statement.
And this function only takes one parameter.
So in this example, we will find out the answer to the question.
What is the average list price of all the product?
So the list price column is in the product table and we will use the product table and here are all
the list prices of the products in the list.
Now, in order to find the average of these prices, the AVG function is used and this function returns
the average value of an expression, and here is the average of the list price of all the product.
Ceiling function now the ceiling function returns the smallest energy value that is greater than or
equal to a particular number.
This function takes only one parameter.
So let's use 15 dots, seven five as the parameter of the ceiling function.
And when we execute the query, we will get 16 as the result.
Because his function returns the smallest integer value that is greater than or equal to the number.
So using 15 dot zero one instead of 15 dot seven five.
We'll also return 16.
The count function.
So the count function is an aggregate that returns the number of records returned by a select query.
So it returns zero if there were no matching rose.
And this function only takes one parameter.
So let's say we want to find out how many products are in the product label.
They can't function requires a parameter, so any column in the table can be used as a parameter.
We can even use multiple columns or a star sign as well.
And this query will get the number of all products from the product table and here it is.
There are 504 products in the product table.
Floor function.
The floor function returns the biggest integer value that is less than or equal to a number.
Here is a syntax of the floor function.
It'll take only one parameter.
So let's use fifteen point seven five as the parameter of the floor function and when we execute the
query, we will get 15 as the result, because this function returns the biggest energy value that is
less than or equal to that number.
So using fifteen point ninety 99 instead of 15 to 25, that's also going to return 15.
Max function.
The max function is an aggregate, the returns, the maximum value in a set of values.
And this is why the syntax looks like the max function, except only one parameter.
So in this example, we will retrieve the biggest list price in the product table.
Now, all we have to do is set a list price as a parameter of the max function and then retrieve it
from the table.
And there it is.
Max function will check all the list prices in the table and then find out what the highest or biggest
one is.
And here is a highest list price in the product table.
Main function, the main function is also an aggregate, the returns, the minimum value in a set of
values.
The main function accepts only one parameter, like the max function, so let's find out where the smallest
this price in the product table is.
So you might be miles ahead of me.
All we have to do is set the list price is a barometer of the mind function and that and then function
will check all the lowest prices in the table and find out the smallest one.
Now, let's see if we can execute the men and max statement together.
So here, the maximum and the minimum list prices in the periodic table.
The power function.
Now, the power function returns the value of a number raised to the power of another number.
This function accepts two parameters, the first parameter is the base and the second parameter is the
exponent.
Both parameters are required.
The number A is the base and the number B is the exponent.
So in this example, we will use to as the base, which is the first parameter and two again is the
exponent, which is the second parameter of this power function.
So this means two to the power of two.
And the result is two times two equals four.
Now, if we change the exponent of five, it means two to the power of five and the result is.
32.
Rand function, the Rand function returns a random number or a random number within a range.
So the RAND function will return a value between zero and one and they are not inclusive, so the value
will be greater than zero and less than one.
So this function takes a seed as a parameter.
So the parameters optional, if a seat is specified, it returns a repeatable sequence of random numbers.
If no seat is specified, it returns a completely random number between zero and one.
And of course, zero and one are not inclusive.
So whenever the query is executed, any random number will be returned.
If the RAND function is used with a number as the parameter, it will return the same random number.
And whenever the query is executed, the same number will be returned.
Now, if we want to get the random decimal numbers, we should multiply it by 10.
So in this case, the random decimal number will be returned between zero and 10 and zero and 10 are
not inclusive.
Now, what about integer numbers?
So if we want to get the random integer numbers, we should multiply the RAND function by 10.
Said it is the parameter of the floor function.
Because you remember that the floor function returns, the energy numbers.
So in this case, the random integer number will be returned between zero and 10 and zero and 10 are
inclusive this time.
Round function.
So the round function rounds a number to a specified number of decimal places.
And this function will take three parameters, the first parameter is the number to be rounded in decimals.
It is required.
The second parameters, a number of decimal places to round the number two, it is required.
And the last parameter is the operation, and that's going to be optional if it's a zero, it rounds
a result to the number of decimals, if it's another value than zero than it truncates, the result
to the number of decimals and the default value is zero.
Great, so let's use one, two, three, three, two, one as the first parameter and three for the
second parameter of the round function.
So the number three, which is the second parameter, is rounded to the number three decimal places.
Now, if we execute the query, we will get all numbers.
If we change the second parameter from three to two.
In this case, it will be rounded to the number to two decimal places.
The numbers, three and two will be returned as the decimal result.
If we use zero as a second parameter in this case, it will be rounded to the number to zero decimal
places.
And if we use minus one, well, a negative number as a second parameter in this case, it will be rounded
one digit to the left.
Security function.
So the rescue party function returns the square root of a number.
So the function takes only one required parameter and the parameter must be a positive number in order
to calculate the square root of whatever the number is.
So the escort is used to find the square root of the specified expression or numeric number.
So if the No.9 is used as a parameter of this function, it will calculate the square root of and it
will return the number three.
The root of number 36 is six.
Square function, so the square function returns the square of a number.
So the function accepts only one required parameter, and it must be a positive number in order to calculate
the square of it.
If the number three is used as the parameter of the square function, it means three times three equals
nine.
And if the number five is the parameter, it means five times five equals 25.
Now, the last function that we're going to learn here is the sum function.
Some function is an aggregate function that calculates the sum of a set of values.
The sum function takes only one parameter.
So let's find out the total of the list prices in the product table, shall we?
All we have to do is set the list price column as a parameter of the sum function and then retrieve
it from the table.
Then the sum function will calculate the sum of the list prices.
And here is the sum of all the list prices in the product table.
That's pretty cool, huh?
So we have now learned the math functions in this section.
We're going to continue, though, because in the following section, we're going to learn you transaction's.
All right, lots of fun.
We'll see you there.