0
我有兩個表分組通過聚合計算
表1:
Unsub|Email|UnsubValue
Y | a | 100
Y | b | 200
N | c | NULL
N | d | NULL
表2:
Email|UnsubValue
a |150
a |200
b |100
b |150
c |300
我要計數具有0或不同的電子郵件的數量1+發生在表2中,其中表2中的未分配值是小於表1中的未分配值。
然後,我想通過表1中的unSub列進行分組。因此,所需的輸出是這樣的:
Unsub| Num Unsub | Count Distinct Email
Y | 0 Unsub | 1 (refers to email a, which has no unsub occurances)
Y | 1+ Unsub | 1 (refers to email b, which has 2 unsub occurances)
N | 0 Unsub | 2 (refers to email c & d, which have no unsub occurances that meet the conditions)
N | 1+ Unsub | 0