Finding and storing groups of rows PK
If you don't need real "pairs" you can get the list of employees sharing a desk using this:

select e1.*
from employees e1
where exists (select *
              from employees e2
              where e1.desk_number = e2.desk_number
                and e1.id &lt;&gt; e2.id);


If you want that as a single "list of IDs" you can use string_agg()

select string_agg(e1.id::text, ',') as id_list
from employees e1
where exists (select *
              from employees e2
              where e1.desk_number = e2.desk_number
                and e1.id &lt;&gt; e2.id);


Or use array_agg() to get those IDs as an array

Online example: http://rextester.com/AXVGA22292