mardi 3 décembre 2019

Sample according to fraction column in SQL?

I am trying to randomly sample a table in SQL according to a user defined probability distribution. I have:

-------------------------------------------
id | bucket | bucket_prob | other_feature |
-------------------------------------------
1       a         0.01         abc
1       a         0.01         def       
2       b         0.03         ghi
3       c         0.04         jkl
3       c         0.04         mno
3       c         0.04         pqr

Is there a SQL query I can write such that the result would be a table where the id's have been sampled according to the bucket_prob column?




Aucun commentaire:

Enregistrer un commentaire