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?

SQLite
RESULTSReady to run
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_idfechatitulounidadesprecio_unitario_euros
10012026-10-04Niebla en Marte145
10012026-10-04Pixel de Medianoche220
10022026-10-06Ritmo de Neón415
10032026-10-14Bosque Binario135
10032026-10-14Islas de Silicio130
10042026-10-27Laberinto Lunar150
10042026-10-27Pixel de Medianoche320
10052026-11-02Pixel de Medianoche220
10052026-11-02Ritmo de Neón215
10062026-11-12Pixel de Medianoche120
10062026-11-12Órbita de Cobre160
10072026-11-20Islas de Silicio230
10072026-11-20Niebla en Marte245
10082026-11-24Bosque Binario135
10082026-11-24Ritmo de Neón315