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