INSERT ALL WHEN nt = 1 THEN INTO t1 VALUES(pk, c1, c2, c3) WHEN nt = 2 THEN INTO t2 VALUES(pk, c1, c2, c3) WHEN nt = 3 THEN INTO t3 VALUES(pk, c1, c2, c3) WHEN nt = 4 THEN INTO t4 VALUES(pk, c1, c2, c3) WHEN nt = 5 THEN INTO t5 VALUES(pk, c1, c2, c3) SELECT pk, c1, c2, c3 , NTILE(5) OVER(ORDER BY pk) nt FROM t ;