邀请好友注册满足条件可获得奖品:统计领奖情况

[b]奖励条目表 award_item:[/b]

[img]http://dl.iteye.com/upload/attachment/455453/94abfdf1-2e29-3453-a593-39807a601731.png[/img]

[b]注册记录表 award_reg_record:[/b]

[img]http://dl.iteye.com/upload/attachment/455455/5d6fabff-1ceb-35a6-86c4-80aae900931c.png[/img]

[b]领取奖品记录表 award_get_record:[/b]

[img]http://dl.iteye.com/upload/attachment/455457/e947d8f9-b165-3e68-97e3-ead48e27ab4c.png[/img]


统计某个任务下满足了领奖条件,但未领奖的人列表及其邀请的好友人数:
[b]not exist方式效率高:[/b]
select user_id, count(new_user_id) from award_reg_record arr
where 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_id
having count(*) > 5

[b]not in 方式效率低:[/b]
select user_id, count(new_user_id) from award_reg_record arr
where user_id not in (select user_id from award_get_record agr where agr.item_id=101)
group by user_id
having count(*) > 5


两种方式的执行结果是一样的:
[img]http://dl.iteye.com/upload/attachment/455461/ccf0ec09-9d7e-38f9-892b-6ff7dfad991d.png[/img]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值