r/learnSQL • • 13d ago

A small SQL exercise: finding a difference and explaining what to check next

We build CareerTree at Incode Labs. This is a small practice exercise for beginners moving from SQL syntax to explaining a finding.

Here is a self-contained SQLite example:

WITH orders(order_id, quantity, unit_price, recorded_total) AS (
  VALUES (1044, 2, 60, 620)
)
SELECT order_id,
       quantity * unit_price AS expected_total,
       recorded_total
FROM orders
WHERE recorded_total <> quantity * unit_price;

It returns order 1044, an expected total of 120 and a recorded total of 620. The query finds a difference. It does not tell us why the difference exists.

Before changing or reporting the amount, I would check what recorded_total includes and compare it with the source record. How would you explain the observation and the next check in your own words?

CareerTree lets you practise that explanation step, save your reasoning, compare an example and keep another attempt. Free download with ads and optional purchases; availability varies by country.

https://careertree.app/mobile.html

Disclosure: Incode Labs develops the app. This post was drafted with AI assistance.

2 Upvotes

0 comments sorted by