Tuesday, March 15, 2016

want to divide table into 10 equal parts

If you want to divide table into 10 equal parts then you might need to min max of number of primary field (field which holds the primary key)
Instead of manual work, you can easily identify the min max for division purpose, you can use below query

select
min(object_id) as v_start
,max(object_id) as v_end
,num
from
(
select 
object_id,
--divide all rows into group number
ntile(10) over (order by object_id) num
from all_objects

group by num;

You can use above logic any where for further logic's. 

No comments:

Post a Comment

web stats