round
Round a number to N decimal places — clean display values and bucketing.
Signature
round(x: Number, [decimals: Int]): NumberReturns
Same type as input
What it does
Rounds a numeric value to N decimal places (default 0). Uses banker's rounding (round half to even). For always-up rounding use ceil(); for always-down use floor().
round() is used to clean up Float64 values from avg() and division before displaying them. It also enables numeric bucketing — round(latency, -2) rounds to the nearest 100 for histogram binning. The optional second argument is the number of decimal places (negative values round to tens/hundreds).
Notes
- ClickHouse uses banker's rounding (half-to-even). Use roundBankers() explicitly if you need documentation clarity.
- Negative decimals round to powers of 10: round(1234, -2) = 1200.
- roundToExp2(x) rounds to the nearest power of 2 — useful for histogram bins.
Example SQL
round in ClickHouse SQL
TypeScript with hypequery
Use round in a typed TypeScript query
hypequery gives you a type-safe query builder for ClickHouse. The generated schema maps your ClickHouse columns to TypeScript types, and raw SQL expressions let you incorporate functions like round when you need them inside a builder query.
Common questions
What developers search for with round
ClickHouse round float to 2 decimal places
round(avg(col), 2) returns a Float64 rounded to 2 decimal places. Useful for currency display without full Decimal arithmetic.
FAQ
Frequently asked questions about round
Does ClickHouse round() use banker's rounding?
Yes. 0.5 rounds to 0 (even), 1.5 rounds to 2 (even). Use roundBankers() to make this explicit, or ceil()/floor() for directional rounding.
Related functions
Functions used alongside round
More function pages are being added. Use the full function index for the currently published reference set.
Related guides
Next step
Use round in a type-safe TypeScript query
hypequery generates TypeScript types from your ClickHouse schema. Use round alongside the builder, and reach for raw SQL expressions when the function is not exposed as a dedicated helper.