mardi 7 juillet 2020

SQL-How to sample my dataset based on condition - (TeraData db)

I have a dataset of 1.5M customers. I grouped the customers based on some field to 12 different groups and these is the distribution:

enter image description here

My mission is to take a sample of 200K customers only, but it must have the same distribution shown here (based on the grouping percentage). Any suggestions? I'm using SQL in Teradata db.

**I looked online for some solutions but with no success. The SAMPLE() function didn't bring me the solution I needed (or maybe I didn't used it right) Thanks!




Aucun commentaire:

Enregistrer un commentaire