Good morning guys, I'd like to know how to do the following SELECT in mysql:
Having the following table, I need to select the last 3 purchase of each Name:
From now on, thanks
Rone,
One option is this:
SELECT A.* FROM COMPRAS A
WHERE (SELECT COUNT(*) FROM COMPRAS B WHERE B.NOME = A.NOME AND B.DATA >= A.DATA) <= 3
ORDER BY NOME, DATA;