sign up today

Ready to Go Pro with Maven Analytics

Ready to Go Pro with Maven Analytics

Sign up today an unlock full access to all data and AI learning content.

free email course

SQL with AI

Day 4

Basic

free email course

SQL with AI

Day 4

Basic

The Brief

Welcome to Day 4! It's still John at Maven Analytics here.

You've connected three tables, found a data quality issue, run a margin analysis, and identified your top customers. Today I'm adding the final tool in this week's toolkit: subqueries.

A subquery is a query inside a query. It lets you answer two-step questions, like "which customers spent more than average?", where you need to calculate the average first, then use it as a filter. You can't do that in a single GROUP BY.

The scenario

Sarah's final brief: "I want to focus retention efforts on high-value customers. Who's above average in spend, and what segments are they in? And are there any products that are significantly over-performing their category average? I want to prioritise those for next quarter's marketing."

Both questions are two-step. Both require subqueries.

Environment Setup

Environment Setup

exercise 1

Find above-average customers

5 min

exercise 1

Find above-average customers

5 min

exercise 2

Find over-performing products within their category

5 min

exercise 2

Find over-performing products within their category

5 min

exercise 3

Put the full picture together for Sarah

5 min

exercise 3

Put the full picture together for Sarah

5 min

Go Deeper

Go Deeper

Looking forward to Tomorrow

Looking forward to Tomorrow

© Maven Analytics, LLC | All Rights Reserved

© Maven Analytics, LLC | All Rights Reserved

© Maven Analytics, LLC | All Rights Reserved