Title - Round SQL function Tags - sql function aggregate

SQL tries to be as precise as possible, and doesn’t round numbers by default, which can make the table difficult to interpret.

The ROUND() function takes a column name and an integer as an argument - inside the parenthesis - then rounds the values in the column to the number of decimals specifed by the integer.

Inside the parenthesis, specify:

  1. the column name you are interested in (as text)
  2. the number of decimal places you want to round the values to (as an integer)

Example:

SELECT ROUND(price, 0) FROM fake_apps;

Will round all of the values in the price column to 0 decimal places (whole numbers).

More complex example:

SELECT ROUND(AVG (price), 2) FROM fake_apps;

Takes the average price and rounds it to 2 decimal places.