本博客只做日常技术经验总结,不涉及真实内容,以下字段均为虚拟。
提取5日内APP自营订单按照支付方式分别计算订单数和用户数
在提数前,查看了表的索引字段,发现时间范围限制字段也在其中,所以弃用平时比较常见的char(created_at,'yyyy-MM-dd'),用大于小于某时间节点来代替函数的使用,极大的加快了运算时间
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19select to_char(created_at,'yyyy-MM-dd') as order_date, COUNT(case when pay_type=411111 then ID END) as 使用云闪付支付订单数, COUNT(distinct case when pay_type=412455 then user_id END) as 使用云闪付支付用户数, COUNT(case when pay_type=398698 then ID END) as 使用applepay支付订单数, COUNT(distinct case when pay_type=399090 then user_id END) as 使用applepay支付用户数, COUNT(distinct user_id) as APP整体自营购物用户数, COUNT(ID) as APP整体自营购物用户数 from ( select ID,user_id,pay_type,CREATED_AT,order_source,order_platform from c_order1 union all select ID,user_id,pay_type,CREATED_AT,order_source,order_platform from c_order2 ) where order_source in (...) and order_platform in (...) and CREATED_AT>=to_date('2022-06-16 00:00:00','YYYY-MM-DD HH24:MI:SS') and CREATED_AT<=to_date('2022-06-20 23:59:59','YYYY-MM-DD HH24:MI:SS') group by to_char(created_at,'yyyy-MM-dd');
最后
以上就是干净奇迹最近收集整理的关于oracle在where条件中关于索引字段的使用注意事项的全部内容,更多相关oracle在where条件中关于索引字段内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复