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