CodeBlanks Logo Icon CodeBlanks

ROUND

Round numbers to a given number of decimals.

ROUND

ROUND rounds a number to a given decimal place. The second argument is the digit count; without it rounds to an integer.

SELECT ROUND(price, 2) AS yuvarlak FROM products;

This query rounds prices to 2 decimal places.

ROUND(price, 2) AS yuvarlak is selected from products.

ROUND — details

ROUND(3.1415, 2) = 3.14; ROUND(3.1415) = 3. A negative digit rounds to tens or hundreds: ROUND(1234, -2) = 1200.

Practice ROUND

Round price to 2 decimal places from products.

Starter code

query.sql
-- round
SELECT
FROM products

Sample solution

query.sql
SELECT ROUND(price, 2) AS yuvarlak
FROM products

Expected output

yuvarlak
5.00
12.50

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is ROUND(3.56, 1)?

  • 4
  • 3.6 Correct answer
  • 3.5
  • 3.56

Explanation: 3.56 to one decimal is 3.6.

2 Round

Question
SELECT ____(price, 2) FROM products;
Answer
SELECT ROUND(price, 2) FROM products;

Explanation: ROUND(price, 2) rounds the number to 2 decimal places.

3 ROUND: match the terms

Term Meaning
ROUND round
CEIL up
FLOOR down
ABS absolute

All lessons in Beginner