liveBook · Manning

Bar function

As explained in DuckDB in Action

The bar function is a DuckDB built-in function that renders values as inline bar charts.

The bar function is a DuckDB built-in that converts numeric values into inline ASCII bar charts. It accepts a value, minimum, maximum, and bar width, returning a string of black blocks. section 10.1.5 section 1.7.4

Chart reputation rates in SQL

WITH top_users AS ( SELECT DisplayName, Reputation, round(reputation / day(today() - CreationDate)) AS rate FROM users WHERE Reputation > 1000000 ) SELECT DisplayName, Reputation, rate, bar(rate, 150, 300, 35) AS bar FROM top_users ORDER BY rate DESC; The result adds a fixed-width visual bar beside each user's reputation rate, making rankings easier to scan directly in DuckDB output.

How DuckDB in Action covers it

How deep it goes
Defines the four arguments and demonstrates a complete CTE-based query, but does not explain rendering internals.
Examples
Uses Stack Overflow users, reputation rates, a CTE, and 35-character black-block bars.
What it assumes
Assumes a queryable dataset and basic SQL, while demonstrating common table expressions within the workflow.
What you can do after
Apply it via DuckDB SQL to turn numeric query columns into compact inline charts.
How it connects
Connects SQL queries, common table expressions, DuckDB, and terminal data visualization.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of DuckDB in Action. The section links point to the parts of the book it draws on.