Как можно различить сумму счета для разных торговцев? - PullRequest
0 голосов
/ 13 марта 2020

Ниже приведен запрос, который я пробовал:

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 

Результат:

enter image description here

Но я хочу sum_gender другого merchant_id

1 Ответ

0 голосов
/ 13 марта 2020

Попробуйте это:

SELECT k.MerchantOfferMerchantID,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.MerchantOfferMerchantID

ORDER BY k.MerchantOfferMerchantID DESC
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...