PostgreSQLNumeric FunctionsWIDTH_BUCKET
LEAST

WIDTH_BUCKETNumeric Functions

RADIANS

Returns the bucket number for a value in n equal-width buckets.

Syntax

WIDTH_BUCKET(v, lo, hi, n)

Example

Enter values below to update the example in real time.

product_name
price
price_bucket
products
-- 가격을 5개 구간으로 분류
SELECT product_name, price,
       WIDTH_BUCKET(price, 0, 100000, 5) AS price_bucket
FROM products;