select specified number of unique IDs where second column is unique
SELECT id,
       sec
FROM (
  SELECT id,
         sec,
         row_number() OVER (PARTITION BY sec ORDER BY id DESC) AS rn
  FROM my_table
) t
WHERE rn = 1
ORDER BY id DESC 
LIMIT 4;


SQLFiddle example: http://sqlfiddle.com/#!15/1ca01/1