select *
from
(
select t.*,row_number() over(partition by 客户名称,月份)rn
from
(select 客户名称,substr(月份,1,6) 月份,成绩 from tb where 成绩=0)t
)
where rn>=3;
from
(
select t.*,row_number() over(partition by 客户名称,月份)rn
from
(select 客户名称,substr(月份,1,6) 月份,成绩 from tb where 成绩=0)t
)
where rn>=3;
(select uname, count(*) as unum
from (select uname, to_char(udate, 'yyyy-mm') as mdate, count(*) as unum
from a
where a.usore = 0
and months_between(trunc(sysdate, 'dd'), trunc(udate, 'dd')) = 3
group by uname, to_char(udate, 'yyyy-mm')) t
where t.unum > 0)tt, b
where tt.uname = b.uname(+)
and tt.unum =3
首先呢,不管语句对不对,我觉得能不用distinct的话,还是少用吧!