mercredi 14 octobre 2020

Randomly splitting records in Vertica into Test and Control

I am working on a use case to partition records by date and randomly assign 80% of the records into Test and 20% into Control in Vertica. How can this be done using SQL.

**For example, Data may look like this:**
UserA 01/01/2000
UserB 01/01/2000 
UserC 01/01/2000 
UserD 01/01/2000 
UserE 01/01/2000
...  
UserF 02/02/2001
UserG 02/02/2001 
UserH 02/02/2001 
UserI 02/02/2001 
UserJ 02/02/2001

**Output should look like:**
UserA 01/01/2000 Test
UserB 01/01/2000 Control
UserC 01/01/2000 Test
UserD 01/01/2000 Test
UserE 01/01/2000 Control
...
UserF 02/02/2001 Control
UserG 02/02/2001 Test
UserH 02/02/2001 Test
UserI 02/02/2001 Test
UserJ 02/02/2001 Control



Aucun commentaire:

Enregistrer un commentaire