Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

sql
databases
communitycreator

What is the SQL MIN() function?

NDUKWE CHIDERA K.

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

The SQL MIN() is a computational command in the structured query language. It performs computations on table columns.

It will return the least value from the selected column.

Syntax

```
SELECT MIN(column_name)
FROM table_name
WHERE condition;
```

Explanation

  • The SELECT clause will select the specified column from the database table.

  • The MIN() function, with column_name as parameter, fetches the least value from the table. column_name is the name of the column to be worked on.

  • If any conditions are available, the where clause provides you with the avenue to use it.

Example

We create an employee biodata table, bio_data.

bio_data

id

idCardNo

fname

lname

age

1

2019rt500

James

Micheal

16

2

2020rt089

Jonah

Tyron

38

3

2000rt410

Juan

Obodo

18

4

2019rt0210

Ella

Fella

90

This table can be queried with the following SQL statement:

SELECT MIN(age)
FROM bio_data
WHERE id > 0

With this query, the smallest age value will be selected and displayed. The select query output should look like this:

bio_data view

RELATED TAGS

sql
databases
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring