IT IS NOT THE SAME QUESTION AS : Using LIMIT within GROUP BY to get N results per group?
but i admit it is similar.
I need to select the first 2 rows per person. the rows are ordered by Year received
Problem : there is a possibility than 2 data were entered the same month (Date is entered YYYY-MM)
The query I came with (following the referred question) is stuck in an BIG loop.
SELECT *
FROM `table_data` as b
WHERE (
    SELECT count(*) FROM `table_data` as a
        WHERE a.Nom = b.Nom and a.year < b.year
    ) <= 2;
Sample Data :
  A  |   year   |  Nom
---------------------
  b  |  2011-01 | Tim
---------------------
  d  |  2011-01 | Tim
---------------------
  s  |  2011-01 | Tim
---------------------
  a  |  2011-03 | Luc
---------------------
  g  |  2011-01 | Luc
---------------------
  s  |  2011-01 | Luc
Should export :
  A  |   year   |  Nom
---------------------
  b  |  2011-01 | Tim
---------------------
  d  |  2011-01 | Tim
---------------------
  a  |  2011-03 | Luc
---------------------
  g  |  2011-01 | Luc
 
     
    