select sum(1),count(distinct product_no) from
(select product_no ,last_time ,time,,last from
(select a.* ,lead() over(partition by product_no order by time ) last ,
lead(time) over(partition by product_no order by time ) last_time from tmp_aaa a order by 1,2
) t where = '出' and last ='近'
) m问题就是处在lead() over 这个分析函数上面 每次查询最终的结果量级都不一样(到那时如果把表T存入新建临时表中就不会),求大拿告知 是什么愿意 ?? 是不是在一个SQL中 lead() over 得到的字段不能直接做条件用?
(select product_no ,last_time ,time,,last from
(select a.* ,lead() over(partition by product_no order by time ) last ,
lead(time) over(partition by product_no order by time ) last_time from tmp_aaa a order by 1,2
) t where = '出' and last ='近'
) m问题就是处在lead() over 这个分析函数上面 每次查询最终的结果量级都不一样(到那时如果把表T存入新建临时表中就不会),求大拿告知 是什么愿意 ?? 是不是在一个SQL中 lead() over 得到的字段不能直接做条件用?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货