Gør dette som en deltagelse i stedet:
SELECT T.*
FROM T join
(SELECT DISTINCT COMPANY_ID
FROM T
ORDER BY 1 DESC
LIMIT N
) TN
on TN.COMPANY_ID = T.COMPANY_ID;
Eksplicitte joinforbindelser fungerer ofte bedre end in
i where
klausul.