I have got two tables, first one called card
:
| card_id | card_name |
And table withdrawal
:
| withdrawal_id | card_id | transaction_date |
I want to get the last four transaction_dates for each card_id.
I tried this code but it wouldn't give the last 4 dates:
SELECT a.card_id, b.transaction_date
FROM card AS a
JOIN withdrawal AS b ON a.card_id = b.card_id
GROUP BY a.card_id, b.transaction_date
ORDER BY a.card_id, b.transaction_date
What do I need to change?