I have an assignment where I need to write a SQL Query that would retrieve the player number and the total amount paid in penalties for players who are captains and have paid more than £80 in total for penalties.

I've got three tables

Players (**playerNo**, name, initials, street, town, postcode)

Teams (**teamNo**, playerNo, division)

Penalties (**paymentNo**, playerNo, penDate, amount)

bold text indicates the primary key. The playerNo in Teams table indicates the team captain.

I don't know how to join three tables. But my attempt at this is:

```
SELECT p1.playerNo, SUM(p2.amount)
FROM Players p1 INNER JOIN Teams t
   ON p1.playerNo = t.playerNo 
JOIN penalties p2
   ON p2.playerNo = p1.playerNo
GROUP BY playerNo
HAVING SUM(p2.amount) > 80;

```

Is any of this correct?