How MIN_BY() Works in DuckDB

DuckDB has a min_by() function that’s similar to the min() function, but with a twist. While the min() function simply returns the minimum value, the min_by() function finds the row with the minimum value in one column and returns the corresponding value from another column at that row.

Here are some examples that demonstrate how it works.

Read more

2 Ways to Add Days to a Date in DuckDB

One common operation you may find yourself doing occasionally in DuckDB is adding intervals to date and/or time values. DuckDB provides us with a couple of easy ways to do this.

Here are two ways to add days to a date in DuckDB.

Read more

RESERVOIR_QUANTILE() Examples in DuckDB

DuckDB includes a reservoir_quantile() function that allows us to compute approximate quantiles efficiently. It provides the approximate quantile using reservoir sampling. This function can be handy when working with large datasets where exact quantile computation would be too slow or resource-intensive.

In this article, we will explore how the reservoir_quantile() function works, along with examples to demonstrate its usage.

Read more

A Quick Look at DuckDB’s CURRENT_DATE Function

DuckDB is an in-process SQL OLAP database management system designed for analytical workloads. It is known for its speed, efficiency, and ease of use. One of the many functions DuckDB provides is current_date, which is useful for working with date-related data.

In this article, we’ll look at how the current_date function works, along with some straightforward examples.

Read more

How to Create a Unique Index in SQLite

SQLite is a lightweight, serverless SQL database engine commonly used for developing mobile applications, web applications, and embedded systems. Among its various functionalities, SQLite allows developers to create indexes, including unique indexes, to enhance data retrieval speed and enforce constraints on data integrity.

A unique index ensures that all values in a specific column, or combination of columns, are distinct, preventing duplicate entries.

In this guide, we’ll walk through the basics of unique indexes in SQLite, explore when and why to use them, and provide examples of how to create them.

Read more