Подача данных для тестирования:
set dateformat ymd
declare @aux table (propertyId int, groupId int,[date] datetime, quantity int, rate money)
insert into @aux values (3475,616375,'2018-09-21',25,139.99)
insert into @aux values (3475,626696,'2018-09-21',6,144.99)
insert into @aux values (3475,602361,'2018-09-21',25,134.99)
insert into @aux values (3475,622321,'2018-09-21',5,119.99)
insert into @aux values (3482,609348,'2018-09-21',11,139.99)
insert into @aux values (3482,621872,'2018-09-21',5,75)
insert into @aux values (3482,614956,'2018-09-21',25,114.99)
insert into @aux values (3482,583585,'2018-09-21',10,139)
insert into @aux values (3488,627286,'2018-09-21',11,164.99)
insert into @aux values (3488,619219,'2018-09-21',5,129.99)
insert into @aux values (3488,603781,'2018-09-21',2,149.99)
insert into @aux values (3488,583573,'2018-09-21',2,0)
Предлагаемое решение:
select a.*
,(select sum(quantity)
from @aux
where [date] = a.[date]
and propertyId = a.propertyId
) sumQuantity
from @aux a
join (
select x.*
,(select max(rate)
from @aux
where [date] = x.[date]
and propertyId = x.propertyId
and quantity = x.qt
) rt
from (select [date]
,propertyId
,max(quantity) as qt
from @aux
group by [date], propertyId
) x
) b on a.[date] = b.[date]
and a.propertyid = b.propertyid
and qt = a.quantity
and rt = a.rate