Skip to Content
0
Nov 07, 2019 at 10:31 AM

Divide the table randomly into two parts

116 Views Last edit Nov 07, 2019 at 10:31 AM 2 rev

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