优雅de程序员 2016-04-14 16:00 采纳率: 0%
浏览 1419
已结题

查询一个表用户对新增用户进行统计不能用not in 需要用exists

下面是用not in 实现的 ,需要修改为 exists实现
SELECT COUNT(*) from order_info_ref as oif where oif.order_time>='2016-03-02 00:01:00' and oif.order_time<='2016-03-02 23:59:59' and oif.ca_user_id NOT in
(SELECT oi.ca_user_id from order_info_ref as oi where oi.order_time>='2016-03-01 00:01:00' and oi.order_time<='2016-03-01 23:59:59');

  • 写回答

1条回答 默认 最新

  • devmiao 2016-04-14 20:23
    关注

    其实两种写法都是可以得,看你的需求了。

    评论

报告相同问题?