Using the .nullvalue Command to See NULL Output in the DuckDB CLI

By default, when a query returns a null value in the DuckDB command line interface (CLI), an empty string is displayed. This may or may not be what you want. But if you’re like me, you probably want DuckDB to explicitly tell you that it’s a null value. After all, if an empty string is returned, perhaps the data contained an empty string?

Fortunately, DuckDB provides us with the .nullvalue dot command so that we can change the output of null values.

Continue reading

How to Format Dates in DuckDB

When working with SQL databases such as DuckDB, dates usually conform to a specific format. In particular, when we create dates in DuckDB, they must conform to the ISO 8601 format (YYYY-MM-DD). It’s the same with time (hh:mm:ss[.zzzzzz][+-TT[:tt]]) and timestamp values (YYYY-MM-DD hh:mm:ss[.zzzzzzzzz][+-TT[:tt]]).

But what if we have a requirement to present these dates or timestamps in a different format?

Fortunately, DuckDB provides us with tools to so. This article explains how to format date and timestamp values according to a specified format.

Continue reading

A Quick Look at the LIST() Function in DuckDB

DuckDB, an in-memory analytical SQL database management system, provides a good selection of functions for data manipulation and analysis. One of the these functions is list().

The list() function enables users to group multiple values into a single list, allowing for more advanced data aggregation and operations.

In this article, we’ll explore how the list() function works, along with some simple examples.

Continue reading