Menu

SQL: The Monthly Revenue Report in Five Lines (GROUP BY Month Instead of a Spreadsheet Every Month-End)
📰

SQL: The Monthly Revenue Report in Five Lines (GROUP BY Month Instead of a Spreadsheet Every Month-End)

DEV Community: database·Robert Breen·2 days ago
#CwxVRdmx
#devtodatabase#devto#dev#orders#month
Reading 0:00
15s threshold

Every month-end, the owner of a small business asks the same two questions: how much did we sell, and how did each month do?

In a lot of offices the answer is a spreadsheet. Someone exports the orders, pastes them in, and adds them up by month. It takes most of an hour, and it goes wrong the month somebody misses a row.

If the orders already live in a database, that hour is four short queries. And next month you don't redo anything. You just run them again.

Here's the version from my free lesson, with a small made-up table you can paste into DB Fiddle (free, no account, pick MySQL).

The orders table

Lakeside Office Supply is a made-up shop with eight orders across one quarter.…

Continue reading — create a free account

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