Ниже приведен запрос, который я пробовал:
select distinct MerchantOfferMerchantID ,c.PsmHaendlerName as Merchant_name, MerchantOfferUpdateDateUTC,
t.MerchantOfferPropertyColumnName , s.MerchantPdlMappingColumnMerchant as Coloumn_Mapped,
sum(count(t.MerchantOfferPropertyValueBigint)) over() as SUM_GENDER
from OFFERPART2.TBLMERCHANTOFFER k
join OfferPart2.TBLMERCHANTOFFERPROPERTY t on k.MerchantOfferIdentHash = t.MerchantOfferPropertyMerchantOfferIdentHash
join copy.tblPsmHaendler as c on k.MerchantOfferMerchantID = c.PsmHaendlerID
join copy.tblMerchantPdlSpecification q on k.MerchantOfferMerchantID = q.MerchantPdlSpecificationMerchantID
join copy.tblMerchantPdlMapping s on q.MerchantPdlSpecificationID = s.MerchantPdlMappingMerchantPdlSpecificationID
where MerchantOfferPropertyColumnName like '%gender%' and MerchantPdlMappingColumn
like'%Gender%' and MerchantOfferUpdateDateUTC > getdate()-0.5
group by k.MerchantOfferUpdateDateUTC , t.MerchantOfferPropertyColumnName , MerchantOfferMerchantID , c.PsmHaendlerName , s.MerchantPdlMappingColumnMerchant
order by MerchantOfferUpdateDateUTC desc
Результат:
Но я хочу sum_gender другого merchant_id