SQL MIN() and MAX() Functions
The SQL MIN() and MAX() functions are used to return the minimum and maximum values from the selected column.
MIN() :- Returns Smallest value.
MAX() :- Returns Largest value.
MIN() Functions Syntax :
The syntax of the MIN() Functions is −
SELECT MIN(column-name)
FROM table-name
WHERE condition;
This will return the smallest value from the column-name records fulfilling the WHERE condition.
MAX() Functions Syntax :
The syntax of the MAX() Functions statement is −
SELECT MAX(column-name)
FROM table-name
WHERE condition;
This will return the Largest value from the column-name records fulfilling the WHERE condition.
MIN() and Max() Function Example :
Consider the Customer table with the following records -
CustomerID |
CustomerName |
Age |
Address |
CustomerSalary |
1 |
Aarav |
28 |
Udaipur |
28000 |
2 |
Vivaan |
25 |
Mumbai |
30000 |
3 |
Reyansh |
28 |
Chennai |
35000 |
4 |
Muhammad |
24 |
Udaipur |
50000 |
5 |
Sai |
30 |
Mumbai |
27000 |
TEST CASE 1 :- The following code is an example, which would return minimum age from the record of Customer table.
SELECT MIN(Age) AS SmallestAge
FROM Customer;
The result for the respective sql query is as follows −
TEST CASE 2:- The following code is an example, which would return maximum age from the record of Customer table.
SELECT MAX(Age) AS LargestAge
FROM Customer;
The result for the respective sql query is as follows −
Visit :
Discussion
pHqghUme
-1 OR 2+947-947-1=0+0+0+1 --
pHqghUme
-1 OR 3+947-947-1=0+0+0+1 --
pHqghUme
-1 OR 3*2<(0+5+947-947) --
pHqghUme
-1 OR 3*2>(0+5+947-947) --
pHqghUme
-1 OR 2+749-749-1=0+0+0+1
pHqghUme
-1 OR 3+749-749-1=0+0+0+1
pHqghUme
-1 OR 3*2<(0+5+749-749)
pHqghUme
-1 OR 3*2>(0+5+749-749)
pHqghUme
-1' OR 2+726-726-1=0+0+0+1 --
pHqghUme
-1' OR 3+726-726-1=0+0+0+1 --
pHqghUme
-1' OR 3*2<(0+5+726-726) --
pHqghUme
-1' OR 3*2>(0+5+726-726) --
pHqghUme
-1' OR 2+159-159-1=0+0+0+1 or 'gIS0e7SU'='
pHqghUme
-1' OR 3+159-159-1=0+0+0+1 or 'gIS0e7SU'='
pHqghUme
-1' OR 3*2<(0+5+159-159) or 'gIS0e7SU'='
pHqghUme
-1' OR 3*2>(0+5+159-159) or 'gIS0e7SU'='
pHqghUme
-1" OR 2+487-487-1=0+0+0+1 --
pHqghUme
-1" OR 3+487-487-1=0+0+0+1 --
pHqghUme
-1" OR 3*2<(0+5+487-487) --
pHqghUme
-1" OR 3*2>(0+5+487-487) --
pHqghUme
if(now()=sysdate(),sleep(15),0)
pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z
pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z
pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/
pHqghUme
-1; waitfor delay '0:0:15' --
pHqghUme
-1); waitfor delay '0:0:15' --
pHqghUme
1 waitfor delay '0:0:15' --
pHqghUme
kw8o6Skn'; waitfor delay '0:0:15' --
pHqghUme
-5 OR 80=(SELECT 80 FROM PG_SLEEP(15))--
pHqghUme
-5) OR 950=(SELECT 950 FROM PG_SLEEP(15))--
pHqghUme
-1)) OR 259=(SELECT 259 FROM PG_SLEEP(15))--
pHqghUme
FKESoFvY' OR 412=(SELECT 412 FROM PG_SLEEP(15))--
pHqghUme
oI00qDAH') OR 965=(SELECT 965 FROM PG_SLEEP(15))--
pHqghUme
RItCcm5o')) OR 233=(SELECT 233 FROM PG_SLEEP(15))--
pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)
pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'