← Retour au blog
tech 24 June 2026

Statistics Directly in Your SQL with the-stats-duck

Discover how the-stats-duck turns DuckDB into a powerful statistical engine, enabling complex analyses directly from SQL.

Article inspired by the original source
Statistics that live in your SQL ↗ kolistat.com

Introduction

In the ever-evolving world of technology, the accessibility and speed of statistical analyses are crucial for decision-makers and developers. With the release of version 0.6.0 of the-stats-duck, an open-source DuckDB extension, conducting complex statistical analyses directly from SQL has never been easier. This version, ironically named "i-m-not-dead," proves that statistics can live and breathe within your database without needing to leave your SQL environment.

Table Profiling at a Glance with meta()

When you're handed a new dataset, the first step is often to "look" at it more closely. The meta() function simplifies this task by providing a complete profile of each column in your table. Imagine working with the famous Palmer Penguins dataset. With a single SQL command, you can glean information such as the number of missing values, mean, median, and more. It surpasses DuckDB's built-in SUMMARIZE function by offering flexibility to integrate with other SQL queries.

Linear Regression Without Leaving SQL

Linear regression is an essential method in statistics, and now it's available directly in SQL thanks to lm() and lm_summary(). For example, to analyze the relationship between penguins' body mass and other physical characteristics, you just need to craft an R-style formula that lm() can interpret. The results include coefficient tables and model statistics like R², making it easy to develop predictive analyses directly in your database.

Confidence Intervals with bootstrap()

Confidence intervals are crucial for assessing the reliability of estimates. The bootstrap() function allows you to calculate these intervals without assuming normality, enabling iterative resampling. For instance, for the penguins' body mass, you can easily compute a 95% confidence interval with a direct SQL command. It's a powerful tool for analysts looking to avoid biases from unverified assumptions.

Direct Visualization from SQL

One of the most intriguing features of the-stats-duck is the ability to generate charts directly from SQL. With VISUALIZE … DRAW, you can create visualizations like scatter plots with fitted regression lines. This enables integrating visual analyses into existing SQL workflows without needing to resort to external tools.

Performance and New Distributions

With version 0.6.0, the speed of read_stat has increased by 52 times, demonstrating a commitment to continuous performance improvement. Additionally, ten new distributions have been added, further expanding the statistical capabilities of the extension.

Conclusion

The-stats-duck is more than just an extension; it's a revolution in how statistical analyses are integrated into SQL databases. For decision-makers and developers, it opens up endless possibilities for advanced analytics directly in their usual workflow. Let's discuss your project in 15 minutes.

Call to Action

Let's discuss your project in 15 minutes.

DuckDB SQL Statistiques Analytique the-stats-duck
Deepthix newsletter · 100% AI · every Monday 8am

An AI agent reads tech for you.

Our AI agent scans ~200 sources per week and ships the best articles to your inbox Monday 8am. Free. One click to unsubscribe.

Visit the newsletter page →

Want to automate your operations?

Let's talk about your project in 15 minutes.

Book a call