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 (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;

No comments:

Post a Comment

web stats