Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
ROUNDing | Aggregating
SQL Basics
course content

Contenido del Curso

SQL Basics

SQL Basics

1. Selecting
2. Filtering
3. Aggregating
4. Sorting
5. Grouping
6. Practicing

ROUNDing

In the last chapter, you solved the task and received a number with many digits after the decimal place. This is surely precise, but not representative, as there is no way to pay 0.002$, for example. It would be great if we could round numbers to some digits.

Surely it's also implemented into SQL! To round number to n decimal places use ROUND(column_name, n) function. For example, from our audi_cars dataset let's calculate the average price of TT model cars with mileage less than 3000 and round the result to 0 decimals (so it will be an integer).

123
SELECT ROUND(AVG(price), 0) FROM audi_cars WHERE model = 'TT' AND mileage < 3000
copy

That's more representative!

Tarea

From the audi_cars table calculate the average price for Petrol cars (column fueltype) with Semi-Auto transmission (column transmission). Round the result to 2 digits after the comma.

Tarea

From the audi_cars table calculate the average price for Petrol cars (column fueltype) with Semi-Auto transmission (column transmission). Round the result to 2 digits after the comma.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 3. Capítulo 4
toggle bottom row

ROUNDing

In the last chapter, you solved the task and received a number with many digits after the decimal place. This is surely precise, but not representative, as there is no way to pay 0.002$, for example. It would be great if we could round numbers to some digits.

Surely it's also implemented into SQL! To round number to n decimal places use ROUND(column_name, n) function. For example, from our audi_cars dataset let's calculate the average price of TT model cars with mileage less than 3000 and round the result to 0 decimals (so it will be an integer).

123
SELECT ROUND(AVG(price), 0) FROM audi_cars WHERE model = 'TT' AND mileage < 3000
copy

That's more representative!

Tarea

From the audi_cars table calculate the average price for Petrol cars (column fueltype) with Semi-Auto transmission (column transmission). Round the result to 2 digits after the comma.

Tarea

From the audi_cars table calculate the average price for Petrol cars (column fueltype) with Semi-Auto transmission (column transmission). Round the result to 2 digits after the comma.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 3. Capítulo 4
toggle bottom row

ROUNDing

In the last chapter, you solved the task and received a number with many digits after the decimal place. This is surely precise, but not representative, as there is no way to pay 0.002$, for example. It would be great if we could round numbers to some digits.

Surely it's also implemented into SQL! To round number to n decimal places use ROUND(column_name, n) function. For example, from our audi_cars dataset let's calculate the average price of TT model cars with mileage less than 3000 and round the result to 0 decimals (so it will be an integer).

123
SELECT ROUND(AVG(price), 0) FROM audi_cars WHERE model = 'TT' AND mileage < 3000
copy

That's more representative!

Tarea

From the audi_cars table calculate the average price for Petrol cars (column fueltype) with Semi-Auto transmission (column transmission). Round the result to 2 digits after the comma.

Tarea

From the audi_cars table calculate the average price for Petrol cars (column fueltype) with Semi-Auto transmission (column transmission). Round the result to 2 digits after the comma.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

In the last chapter, you solved the task and received a number with many digits after the decimal place. This is surely precise, but not representative, as there is no way to pay 0.002$, for example. It would be great if we could round numbers to some digits.

Surely it's also implemented into SQL! To round number to n decimal places use ROUND(column_name, n) function. For example, from our audi_cars dataset let's calculate the average price of TT model cars with mileage less than 3000 and round the result to 0 decimals (so it will be an integer).

123
SELECT ROUND(AVG(price), 0) FROM audi_cars WHERE model = 'TT' AND mileage < 3000
copy

That's more representative!

Tarea

From the audi_cars table calculate the average price for Petrol cars (column fueltype) with Semi-Auto transmission (column transmission). Round the result to 2 digits after the comma.

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 3. Capítulo 4
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt