Introducing Crunchy Data Warehouse: A next-generation Postgres-native data warehouse. Crunchy Data Warehouse Learn more

Posts about Tutorials

  • 8 min read

    Window Functions for Data Analysis with Postgres

    Elizabeth Christensen

    SQL makes sense when it's working on a single row, or even when it's aggregating across multiple rows. But what happens when you want to compare between rows of something you've already calculated? Or make groups of data and query those? Enter window functions.

    Window functions tend to confuse people - but they’re a pretty awesome tool in SQL for data analytics. The best part is that you don’t need charts, fancy BI tools or AI to get some actionable and useful data for your stakeholders. Window functions let you quickly:

    • Calculate running totals
    • Provide summary statistics for groups/partitions of data
    • Create rankings
    • Perform lag/lead analysis, ie comparing two separate sets of data with each other
    • Compute moving/rolling averages
    Read More
  • 10 min read

    Six Degrees of Kevin Bacon - Postgres Style

    Paul Ramsey

    Back in the 1990s, before anything was cool (or so my children tell me) and at the dawn of the Age of the Meme, a couple of college students invented a game they called the "Six Degrees of Kevin Bacon".

    The conceit behind the Six Degrees of Kevin Bacon

    Read More
  • 7 min read

    Magic Tricks for Postgres psql: Settings, Presets, Echo, and Saved Queries

    Elizabeth Christensen

    As I’ve been working with Postgres psql cli, I’ve picked up a few good habits from my Crunchy Data co-workers that make my terminal database environment easier to work with. I wanted to share a couple of my favorite things I’ve found that make getting around Postgres better. If you’re just getting started with psql, or haven’t ventured too far out of the defaults, this is the post for you. I’ll walk you through some of the friendliest psql settings and how to create your own preset settings file.

    Some of the most helpful psql commands

    Read More