Filtering by minimum value per group problem
To get the desired result from your sample table,

select tgroup, name, id 
from 
(
    select tgroup, name, id, row_number() over (partition by tgroup order by id) rn 
    from (&lt;&lt;your subselect&gt;&gt;) 
 ) 
 where rn = 1


I've renamed group to tgroup as group is a reserved word in SQL.

SQLFiddle

As for your real query, please first make it readable.