邀请好友注册满足条件可获得奖品:统计领奖情况
奖励条目表 award_item:
注册记录表 award_reg_record:
领取奖品记录表 award_get_record:
统计某个任务下满足了领奖条件,但未领奖的人列表及其邀请的好友人数:
not exist方式效率高:
select user_id, count(new_user_id) from award_reg_record arrwhere not exists (select user_id from award_get_record agr where agr.user_id=arr.user_id and agr.item_id=101)group by user_idhaving count(*) > 5
not in 方式效率低:
select user_id, count(new_user_id) from award_reg_record arrwhere user_id not in (select user_id from award_get_record agr where agr.item_id=101)group by user_idhaving count(*) > 5
两种方式的执行结果是一样的:
