I would change Martin's solution a bit:
select place, sum(bytes), max(case when seqnum = 1 then user end) as random_user from (select place, bytes, row_number() over (partition by place order by newid()) as sequm from t ) t group by place
(Where newid () is just one way to get a random number, depending on the database.)
For some reason, I prefer this approach because it still has an aggregate function in the outer query. If you summarize a bunch of fields, then this seems to me cleaner.
Gordon linoff
source share