Skip to content
Buy the course

Why does your agent's revenue number differ from finance's?

One question about Q3 revenue gets three answers from the same tables. Run the query that gets the first one and see what it counted.

Sample page. Your Maestro, an AI, answers your free questions about this page.

Before you start, one quick question. It doesn't count for anything: it's your starting point, and you'll see the same question again at the end of the course.

Check yourself, Starting point: An agent can query a shop's raw tables (orders, order items, customers, refunds) but has nothing else. Which of these can it NOT find out from the data alone?

Mark where you start: at the end you'll see how far you've come.

Ridgeline Coffee Roasters is a small US roaster (made up, like everything in this course) that sells beans and gear online and to cafes. Its shop app exports six tables to the warehouse every night. Finance asks one question: what was net revenue by region in Q3 2026?

The same tables give three different answers, depending on who asks and what they know:

Who answeredQ3 net revenue
A query that joins everything and sums it$88,435.40
Claude Code, given the raw tables$76,137.00
Finance, using the model you build in this course$75,638.50

The second row is a real run: Claude Code (Sonnet 5.5) answered this question on these tables on October 31, 2026, and you'll read its whole session on the next page. Nobody made a math error. Each answer counted different rows.

Try it

The query below is the first answer: it joins orders to their lines and adds up every line plus the shipping on the order. Run it and you get $88,435.40. Then fix the two problems you can see in the data itself: keep only completed orders, and count only what the customer paid for the items (shipping is not revenue). You're done when the total reads 78,132.00.

Your turn

Run the query to see $88,435.40. Then keep only orders whose status is 'completed', and stop adding shipping_usd. You're done when one row comes back with revenue 78132.0.

Tables: orders (order_id, customer_id, ordered_at, status, shipping_usd), order_items (order_item_id, order_id, product_id, quantity, unit_price_usd)

orders · 640 rows

ColumnType
order_id The order. Unique.VARCHAR
customer_idVARCHAR
ordered_at UTCTIMESTAMP
status completed or cancelledVARCHAR
shipping_usd Shipping charged on the whole order, in US dollarsDOUBLE

First rows

order_idcustomer_idordered_atstatusshipping_usd
R1558C0032026-06-15T09:49:37completed0.00
R1274C0202026-06-15T12:02:40completed0.00
R1060C0422026-06-15T15:07:19completed5.95

order_items · 1,202 rows

ColumnType
order_item_id One line of an orderVARCHAR
order_id The order this line belongs to (raw_orders.order_id)VARCHAR
product_id The product sold (raw_products.product_id). P13 is a holiday blend deleted from the catalogVARCHAR
quantityBIGINT
unit_price_usd The price the customer paid for one unitDOUBLE

First rows

order_item_idorder_idproduct_idquantityunit_price_usd
L00001R1001P1017
L00002R1002P07134
L00003R1003P091119

At 78,132.00 you've done what any careful analyst does with a new table: looked at the columns and used what they say. Subtract the $1,995.00 in refunds on those orders and you reach $76,137.00, which is exactly where Claude Code landed.

It's still $498.50 too high. The difference comes from something no column tells you, and that's the subject of this course: the rules your company runs on are not in the data, so an agent can't follow them until you put them where it reads. Where does the other $498.50 come from?

Check yourself: Your agent and finance disagree about Q3 revenue by $498.50. Both used the same tables and neither made an arithmetic mistake. What's the most likely cause?

This page is from the course; the rest waits in it.