task Join fan-out & cardinality · medium
Orders whose payments don’t match
For sale orders placed in November 2011, return order_id, order_total (sum of quantity × unit_price, rounded to 2) and captured (sum of captured payments, rounded to 2, 0 when none) for orders whose captured amount differs from the order total.
what to return
- Columns
order_idorder_totalcapturedin this order- Rows
- 12 rows · any order
- Skill
- Join independent children at the parent grain. Refresher: Revenue & payment reconciliation →
expected result
Your query should return exactly these columns and values. Run it and compare.
| order_id | order_total | captured |
|---|---|---|
| 6154 | 296.76 | 0 |
| 6169 | 300.1 | 0 |
| 6183 | 213.08 | 0 |
first 3 of 12 rows
data you can query
Retail dataset: the first 6 rows of each table. Under each column name: the kind of value it holds, and which table it links to. Your queries run on all rows.
orders6 columns · 6,722 rows
| order_idnumber · unique id | invoice_notext | customer_idnumber · links to customers | ordered_atdate & time | countrytext | order_typetext |
|---|---|---|---|---|---|
| 1 | 489438 | 18102 | 2009-12-01 09:24:00 | United Kingdom | sale |
| 2 | 489517 | 16329 | 2009-12-01 11:34:00 | United Kingdom | sale |
| 3 | C489528 | 16714 | 2009-12-01 11:50:00 | United Kingdom | cancellation |
| 4 | 489529 | 17984 | 2009-12-01 11:51:00 | United Kingdom | sale |
| 5 | 489532 | 13394 | 2009-12-01 11:58:00 | United Kingdom | sale |
| 6 | 489540 | 12913 | 2009-12-01 12:18:00 | United Kingdom | sale |
- order_idnumber · unique id
- 1
- invoice_notext
- 489438
- customer_idnumber · links to customers
- 18102
- ordered_atdate & time
- 2009-12-01 09:24:00
- countrytext
- United Kingdom
- order_typetext
- sale
- order_idnumber · unique id
- 2
- invoice_notext
- 489517
- customer_idnumber · links to customers
- 16329
- ordered_atdate & time
- 2009-12-01 11:34:00
- countrytext
- United Kingdom
- order_typetext
- sale
- order_idnumber · unique id
- 3
- invoice_notext
- C489528
- customer_idnumber · links to customers
- 16714
- ordered_atdate & time
- 2009-12-01 11:50:00
- countrytext
- United Kingdom
- order_typetext
- cancellation
- order_idnumber · unique id
- 4
- invoice_notext
- 489529
- customer_idnumber · links to customers
- 17984
- ordered_atdate & time
- 2009-12-01 11:51:00
- countrytext
- United Kingdom
- order_typetext
- sale
- order_idnumber · unique id
- 5
- invoice_notext
- 489532
- customer_idnumber · links to customers
- 13394
- ordered_atdate & time
- 2009-12-01 11:58:00
- countrytext
- United Kingdom
- order_typetext
- sale
- order_idnumber · unique id
- 6
- invoice_notext
- 489540
- customer_idnumber · links to customers
- 12913
- ordered_atdate & time
- 2009-12-01 12:18:00
- countrytext
- United Kingdom
- order_typetext
- sale
first 6 of 6,722 rows · your queries use all of them
order_items7 columns · 125,613 rows
| order_item_idnumber · unique id | order_idnumber · links to orders | line_numbernumber | stock_codetext · links to products | descriptiontext | quantitynumber | unit_pricedecimal |
|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 21329 | DINOSAURS WRITING SET | 28 | 0.98 |
| 2 | 1 | 2 | 21252 | SET OF MEADOW FLOWER STICKERS | 30 | 1.69 |
| 3 | 1 | 3 | 21100 | CHARLIE AND LOLA CHARLOTTE BAG | 30 | 1.15 |
| 4 | 1 | 4 | 21033 | JUMBO BAG CHARLIE AND LOLA TOYS | 30 | 2 |
| 5 | 1 | 5 | 20711 | JUMBO BAG TOYS | 60 | 1.3 |
| 6 | 1 | 6 | 21410 | COUNTRY COTTAGE DOORSTOP GREEN | 32 | 2.5 |
- order_item_idnumber · unique id
- 1
- order_idnumber · links to orders
- 1
- line_numbernumber
- 1
- stock_codetext · links to products
- 21329
- descriptiontext
- DINOSAURS WRITING SET
- quantitynumber
- 28
- unit_pricedecimal
- 0.98
- order_item_idnumber · unique id
- 2
- order_idnumber · links to orders
- 1
- line_numbernumber
- 2
- stock_codetext · links to products
- 21252
- descriptiontext
- SET OF MEADOW FLOWER STICKERS
- quantitynumber
- 30
- unit_pricedecimal
- 1.69
- order_item_idnumber · unique id
- 3
- order_idnumber · links to orders
- 1
- line_numbernumber
- 3
- stock_codetext · links to products
- 21100
- descriptiontext
- CHARLIE AND LOLA CHARLOTTE BAG
- quantitynumber
- 30
- unit_pricedecimal
- 1.15
- order_item_idnumber · unique id
- 4
- order_idnumber · links to orders
- 1
- line_numbernumber
- 4
- stock_codetext · links to products
- 21033
- descriptiontext
- JUMBO BAG CHARLIE AND LOLA TOYS
- quantitynumber
- 30
- unit_pricedecimal
- 2
- order_item_idnumber · unique id
- 5
- order_idnumber · links to orders
- 1
- line_numbernumber
- 5
- stock_codetext · links to products
- 20711
- descriptiontext
- JUMBO BAG TOYS
- quantitynumber
- 60
- unit_pricedecimal
- 1.3
- order_item_idnumber · unique id
- 6
- order_idnumber · links to orders
- 1
- line_numbernumber
- 6
- stock_codetext · links to products
- 21410
- descriptiontext
- COUNTRY COTTAGE DOORSTOP GREEN
- quantitynumber
- 32
- unit_pricedecimal
- 2.5
first 6 of 125,613 rows · your queries use all of them
payments6 columns · 5,423 rows
| payment_idnumber · unique id | order_idnumber · links to orders | paid_atdate & time | methodtext | amountdecimal | statustext |
|---|---|---|---|---|---|
| 1 | 4 | 2009-12-01 12:02:00 | card | 229.46 | captured |
| 2 | 6 | 2009-12-01 12:52:00 | card | 161.39 | captured |
| 3 | 11 | 2009-12-01 13:14:00 | card | 859.1 | captured |
| 4 | 14 | 2009-12-01 13:26:00 | card | 322.9 | captured |
| 5 | 12 | 2009-12-01 13:27:00 | card | 246.86 | captured |
| 6 | 17 | 2009-12-01 15:14:00 | card | 383.87 | captured |
- payment_idnumber · unique id
- 1
- order_idnumber · links to orders
- 4
- paid_atdate & time
- 2009-12-01 12:02:00
- methodtext
- card
- amountdecimal
- 229.46
- statustext
- captured
- payment_idnumber · unique id
- 2
- order_idnumber · links to orders
- 6
- paid_atdate & time
- 2009-12-01 12:52:00
- methodtext
- card
- amountdecimal
- 161.39
- statustext
- captured
- payment_idnumber · unique id
- 3
- order_idnumber · links to orders
- 11
- paid_atdate & time
- 2009-12-01 13:14:00
- methodtext
- card
- amountdecimal
- 859.1
- statustext
- captured
- payment_idnumber · unique id
- 4
- order_idnumber · links to orders
- 14
- paid_atdate & time
- 2009-12-01 13:26:00
- methodtext
- card
- amountdecimal
- 322.9
- statustext
- captured
- payment_idnumber · unique id
- 5
- order_idnumber · links to orders
- 12
- paid_atdate & time
- 2009-12-01 13:27:00
- methodtext
- card
- amountdecimal
- 246.86
- statustext
- captured
- payment_idnumber · unique id
- 6
- order_idnumber · links to orders
- 17
- paid_atdate & time
- 2009-12-01 15:14:00
- methodtext
- card
- amountdecimal
- 383.87
- statustext
- captured
first 6 of 5,423 rows · your queries use all of them
Hints and the answer are always available. Using them counts the question as solved with help.