i had already given the query which takes care of > 40 and status ='F' and records < 1001
Below is the ntile query for the same which can take care of all the three above.
select filename, status,ntile(5) over(order by filename) mygroup
from (
select from mytable where status='F'
and (select count(*) from mytable where status='F') >40 and rownum < 1001
)
order by mygroup;
I think we do not need the below query as you can easily do it with NTILE function... I am just giving the modified version here as well..
select filename, status, mod(rr,5)+1 mygroup from
(
select filename, status , rownum rr from mytable
where status ='F'
and (select count(*) from mytable where status='F') >40
)
where rr < 1001
orer by mygroup;
Thanks,