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 得到的字段不能直接做条件用?