TRENDING TOPICS

×

SQL MIN() and MAX() Functions

MIN() and MAX() both are SQL functions. The SQL MIN() function used to returns the smallest value of the selected column in a table; The SQL MAX() function used to returns the largest value of the selected column.

MIN() Function Synrtax

SELECT  MIN(column_name)
FROM table_name
WHERE [condition];

MAX() Function Synrtax

SELECT  MAX(column_name)
FROM table_name
WHERE [condition];

Specific Column - SQL MIN() and MAX()

Student Table

A table of student records, the name of table is "Student", and the name of columns are [ROLL_NO, STUDENT_NAME, ADDRESS, MOBILE_NO, AGE, and BRANCH]:

ROLL_NO STUDENT_NAME ADDRESS MOBILE_NO AGE BRANCH
1 Mohit Sharma Delhi XXXXXXXX87 20 IT
2 Pooja Pandit Kolkata XXXXXXXX34 18 CSE
3 Priya Pandey Delhi XXXXXXXX62 19 EEE
4 Mohit Kumar Jha Allahabad U.P XXXXXXXX87 20 ECE
5 Shevani Shree Noida U.P XXXXXXXX51 17 IT
6 Badshah Mumbai XXXXXXXX02 20 Civil
7 Viki Mohan Pune XXXXXXXX72 19 CSE
8 Sona Kaur Indor M.P XXXXXXXX81 22 ME

MIN() Function Example

SELECT  MIN(AGE) AS SMALLEST_AGE
FROM Student;

Result Look Like

SMALLEST_AGE
17

MAX() Function Example

SELECT  MAX(AGE) AS LARGEST_AGE
FROM Student;

Result Look Like

LARGEST_AGE
22

Advertise With Us

We offer sponsored posts and guest posts with do-follow links, back-links, and other advertising services, To advertise email us at "advertise@gdatamart.com"

© 2021 GDATAMART.COM (All Rights Reserved)