INNER JOIN
Read the line items on a receipt
For each order line, which game was sold, on what date, and at what price per copy?
Compare with the solution
Each row shows one game in an order. Order 1002 has a single line for four copies.
SELECT p.id AS pedido_id,
p.fecha,
v.titulo,
lp.unidades,
lp.precio_unitario_euros
FROM pedidos AS p
JOIN lineas_pedido AS lp ON lp.pedido_id = p.id
JOIN videojuegos AS v ON v.id = lp.videojuego_id
ORDER BY p.fecha ASC, p.id ASC, v.titulo ASC;| pedido_id | fecha | titulo | unidades | precio_unitario_euros |
|---|---|---|---|---|
| 1001 | 2026-10-04 | Niebla en Marte | 1 | 45 |
| 1001 | 2026-10-04 | Pixel de Medianoche | 2 | 20 |
| 1002 | 2026-10-06 | Ritmo de Neón | 4 | 15 |
| 1003 | 2026-10-14 | Bosque Binario | 1 | 35 |
| 1003 | 2026-10-14 | Islas de Silicio | 1 | 30 |
| 1004 | 2026-10-27 | Laberinto Lunar | 1 | 50 |
| 1004 | 2026-10-27 | Pixel de Medianoche | 3 | 20 |
| 1005 | 2026-11-02 | Pixel de Medianoche | 2 | 20 |
| 1005 | 2026-11-02 | Ritmo de Neón | 2 | 15 |
| 1006 | 2026-11-12 | Pixel de Medianoche | 1 | 20 |
| 1006 | 2026-11-12 | Órbita de Cobre | 1 | 60 |
| 1007 | 2026-11-20 | Islas de Silicio | 2 | 30 |
| 1007 | 2026-11-20 | Niebla en Marte | 2 | 45 |
| 1008 | 2026-11-24 | Bosque Binario | 1 | 35 |
| 1008 | 2026-11-24 | Ritmo de Neón | 3 | 15 |