A useful error log preserves the question, your first answer, the specific cause of the error, and your next test. Retry the problem without looking at the answer, then solve a variation with one condition changed. Check both the result and whether you can explain your choice.
Keep the first attempt. Forgetting a condition and applying the wrong method need different kinds of practice.
Find the condition your first answer lost
The SQL exercise asks for an order count for each customer, including those with no orders. The first query uses an INNER JOIN. Customers with orders have the right totals, but customers with none disappear.
A LEFT JOIN keeps all customers on the left. COUNT(orders.id) counts matched, non-null order IDs, so a customer with no matching orders gets zero.
Do the original again, then change the context
The following day, read just the question and write the query again. Explain why the customer table goes on the left. Then count refunds by merchant, including merchants who have never received a refund.
| Question | Pass condition |
|---|---|
| Original customer count | Customer with no orders is present with zero |
| Refund variation | Merchant with no refunds is present with zero |
| Explain the method | Explain why you count a matched column |
If your variation reports one refund for a merchant with none, check whether you used COUNT(*). Record the new mistake and test a zero-match case and a case with multiple matches.
Schedule the retry as its own work
In TodoNote, give the closed-book retry and the variation separate dates and group them under the SQL error log tag. Keep the original attempt and append the results of your later tests.
A correction in your note means you have found a likely fix. Complete the practice task once you can produce and test the answer independently.
Review recurring errors together
If several problems lose unmatched rows, give them a specific label such as “preserve the left table.” Explain the shared condition across two examples, then test it on data you have not seen.
Technical reference · PostgreSQL
Related reading · How to make a self-study plan with practice you can actually check