# HackerRank: [SQL Aggregation] (13/17) Weather Observation Station-16 | round, min function in SQL

I started studying SQL from a very famous site - HackerRank. Here I will try to provide multiple approaches & solutions to the same problem. It will help you learn and understand SQL in a better way.

Please make use of my blog posts for learning purpose only and feel free to ask your questions in the comment box below in case of any doubt.

SQL Problem Statement:

Query the smallest Northern Latitude (LAT_N) from STATION that is greater than 38.7780. Round your answer to 4 decimal places.

Input Format:

The STATION table is described as follows:

 Table: STATION
where LAT_N is the northern latitude and LONG_W is the western longitude.

Sample data in Table (STATION):
```ID CITY STATE LAT_N LONG_W
794 Kissee Mills MO 140 73
824 Loma Mar CA 49 131
603 Sandy Hook CT 72 148
478 Tipton IN 34 98
619 Arlington CO 75 93
711 Turner AR 50 101
839 Slidell LA 85 152
.
.
.
754 South Haven MI 145 53
144 Eskridge KS 1```

### Solution: Using ROUND & MIN Function (MySQL Query):

```SELECT ROUND(MIN(LAT_N), 4)
FROM STATION
WHERE LAT_N > 38.7780;```

NOTE:
1. ROUND Function is used to round the decimal numbers up to mentioned length after the decimal point. Here, 4 is passed because we want output scale up to 4 decimal points.
Eg.
ROUND(2.7685, 2) will return 2.77
ROUND(2.3327, 0) will return 2.33
2. MIN is an aggregation function used to get the least (minimum) value of all the records in the column name passed to the function.

### Expected Output:

`38.8526`

--------------------------------------------------------------------------------