How to do group by based on another column in SELECT?

I have a table on which I do a SELECT statement. It is joined to some other tables. With the SELECT one column is got but a sub query. like (select top 1 .. from..) for each row. Now I need to do an aggregation based on that column, so I have to group by id(which I also select) the amounts that I’ve got in that column got by the subquery. Is it possible and how?