Daily product turnover at the bank

Back to lesson

Daily product turnover at the bank

Gazprombank is building a daily-turnover report for its corporate products. Every operation carries a client, a product category and an amount in roubles. Roll the data up to «product + day»: count the operations, sum the turnover and compute the average operation amount. Round the average to two decimals. In PostgreSQL the amount_rub column is typed MONEY. AVG() does not accept it at all, and SUM() returns money — carrying a currency symbol and digit separators. Cast the values to numeric (amount_rub::numeric) so that total_amount and avg_amount come back as plain numbers. In ClickHouse the column is already Decimal, so no cast is needed there.

Any row order

Gazprombank

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid