Sql Group By Select First Occurrence Of An Element