An online retailer stores orders, ordered quantities and payments in three tables. The tables below contain all records relevant to this report. Each line_id and each payment_id is unique. Payments apply to whole orders rather than individual order lines, and all monetary amounts are in Canadian dollars (CAD).
Orders
order_id
910
911
OrderLines
line_id
units
41
3
42
5
43
4
Payments
payment_id
payment_cad
71
30
72
50
73
20
74
25
75
35
An analyst runs:
SELECT SUM(l.units) AS reported_units, SUM(p.payment_cad) AS reported_payments FROM Orders AS o INNER JOIN OrderLines AS l ON o.order_id = l.order_id INNER JOIN Payments AS p ON o.order_id = p.order_id;
Find the reported units and reported payments. Also find the excess units and excess payments, defined as each reported total minus the corresponding total obtained by counting every source detail record once. Enter all four answers as exact integers; enter monetary answers in CAD without a currency symbol.
Unlock full course notes by signing up
Row count of a left join with unmatched rows
The tables below come from a small company database, where each employee belongs to at most one department.
departments
employees
Row counts for every join type
An online shop imported its reviews table from an old system without a foreign-key constraint, so one review refers to a product that no longer exists.
products
reviews
Reading employee and supervisor aliases
A company stores employees and their immediate supervisors in the following Staff table. The column staff_id uniquely identifies each employee, and manager_id contains that employee's supervisor's staff_id. NULL indicates no supervisor.
The company runs this query:
Complete the three output rows below in the order returned by the query. Enter each person's name exactly as shown in the source table.
General properties of equality joins
Two tables A and B are joined with the equality condition A.k = B.k on a column k that exists in both tables, and no WHERE clause is applied. Select every statement that is true for all such tables.