Menu

SQL: Find the Customers Who Stopped Ordering With a LEFT JOIN (and Why a Plain JOIN Hides the One You Most Need to Call)
📰

SQL: Find the Customers Who Stopped Ordering With a LEFT JOIN (and Why a Plain JOIN Hides the One You Most Need to Call)

DEV Community: database·Robert Breen·2 days ago
#LcQUdQ52
#devtodatabase#devto#dev#name#join
Reading 0:00
15s threshold

Most small businesses don't lose customers in one dramatic phone call. They lose them quietly. A dental practice that ordered every month just stops, and nobody notices until the year-end review.

The fix is a list every Monday: customers with no order since a given date, with their account manager next to each name so someone can call.

That list is one query. But there's a trap in it, and the trap hides the customer you most need to call. Here's the query, and the trap, from my free lesson. You can paste everything into DB Fiddle (free, no account, pick MySQL).

Two tables

Lakeside Office Supply is a made-up shop.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.