cancel
Showing results for 
Search instead for 
Did you mean: 

Divide the table randomly into two parts

0 Kudos

I’ve got a table “Case” with 3 million records.
I want to Divide the table randomly into two equal views: “view_1” and “view_2”.
first view is created with no problems, but the second has 0 record. Can anyone help with the second view?

Create view “view_1” as 
(select * from “Case” where rand() < 0.50); 

Create view “view_2” as
(select  * from “Case” as t1 
left join “view_1” as t2 on
t1.* = t2.* where t1.* is null);

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hello Liz,

what about a minus-function for your second view like ...

Create view “view_2” as
(select * from “Case” as t1
minus
select * from "view_1");

This would in my opinion generate the difference between your origin table and the generated view_1 as view_2.


Regards

Markus

0 Kudos

Thank you

Answers (0)