SELECT id, type, lot
FROM (
SELECT id, type, lot, RANK() OVER(PARTITION BY lot ORDER BY type) AS nbInLot
FROM (
SELECT id, type, RANK() OVER(PARTITION BY type ORDER BY id) AS lot
FROM table
ORDER BY 3,1
)
)
WHERE nbInLot <= 2
---------------
C'était vraiment très intéressant.