select uid, (select value from profile_values where fid=24 and uid=pv.uid) as c_bpartner_id, value from profile_values pv where uid in (select uid from profile_values where fid=24) and fid=17 order by c_bpartner_id