APPROX_QUANTILE() Examples in DuckDB

DuckDB is an in-process SQL OLAP database management system designed for analytical workloads. One of its handy features is the ability to compute approximate quantiles efficiently using the approx_quantile() function. This function is particularly useful when working with large datasets where exact quantile computation would be computationally expensive.

In this article, we will explore how the approx_quantile() function works, its syntax, and provide examples to demonstrate its usage.

Continue reading

Understanding DuckDB’s APPROX_COUNT_DISTINCT() Function

DuckDB is an in-process SQL OLAP database management system designed for fast analytical queries. One of its handy features is the approx_count_distinct() function, which provides an approximate count of distinct values in a column. This function is particularly useful when working with large datasets where an exact count would be computationally expensive.

In this article, we’ll explore how approx_count_distinct() works, its benefits, and how to use it with some simple examples.

Continue reading

Fix “Binder Error” When Using COALESCE() in DuckDB

If you’re getting an error that reads something like “Binder Error: Cannot mix values of type …etc” when using the COALESCE() function in DuckDB, it’s probably because you’re using arguments with incompatible types.

To fix this issue, try using CAST() or TRY_CAST() to ensure that all arguments are compatible. Alternatively, make sure the arguments to COALESCE() are of the same type (or at least, compatible types).

Continue reading

Examples that Demonstrate DuckDB’s MIN() Function

DuckDB has a min() function just like most RDBMSs that returns the minimum value from a set of values. However, DuckDB’s implementation also allows us to return the bottom n minimum values, which is not something we see in most other RDBMSs.

This article presents some examples of DuckDB’s implementation of the min() function, so as to demonstrate its basic usage, as well as its bottom n functionality.

Continue reading

Using a CTE with an UPDATE Statement in SQL Server

In SQL Server, Common Table Expressions (CTEs) are often used for readability and simplifying complex queries. While CTEs are most commonly used when running a SELECT query, we can also use CTEs to perform updates with the UPDATE statement. This can be useful when we need to reference the same set of data multiple times or want to update records conditionally.

Continue reading