Data Analytics01
Where to start with data analytics
A practical way to make your first steps feel a little less overwhelming.
Read articleBefore you write a query, get clear on what one row of your answer should represent.
A query is easier to write when you know the shape of the answer. Before choosing functions or joins, describe the result you need in everyday language.
Imagine an orders table. To compare regions, you might want one row per region with its total sales. The region becomes your grouping key and sales becomes your measure.
SELECT region, SUM(sales) AS total_sales
FROM orders
GROUP BY region
ORDER BY total_sales DESC;| Question | SQL concept |
|---|---|
| Which records matter? | WHERE |
| What does one row represent? | GROUP BY |
| Which result comes first? | ORDER BY |
Check whether sales values can be missing, whether orders contain duplicate rows and whether your date range matches the question. A query can run successfully and still answer the wrong question.