How to add template in codeigniter |how to create template in codeigniter| template in codeigniter 4
Today I am going to discuss some sql query functions.These functions are basically used to calculate data from a table.Here I am showing you a table of the user and how will you use this function to calculate.
ID | Name | Age |
---|---|---|
1 | Roy | 25 |
2 | Shyam | 30 |
3 | Raj | 32 |
Min
In this query, We are fetching the row which holds minimum age.
SELECT MIN(Age) AS smallage FROM user;
Output
ID | Name | Age |
---|---|---|
1 | Roy | 25 |
Max
In this query, we are fetching the row which holds maximum age.
SELECT MAX(Age) AS maxage FROM user;
ID | Name | Age |
---|---|---|
3 | Raj | 32 |
Count
In this query, we are calculating how many numbers of the row in the table.
SELECT COUNT(ID) as total FROM user;
Output
Total |
---|
3 |
Avg
In this query, we are calculating average age from the user table.
SELECT AVG(Age) as avgage FROM user;
Output
avgage |
---|
29 |
Sum
In this query, we are calculating total age from user table.
SELECT SUM(Age) as totalage FROM user;
Output
totalage |
---|
87 |
Related posts