dimanche 16 octobre 2022

How to generate random 0 and 1 with 80-20 probability in sql server

I have a Table with 10 records, I have a column (name:RandomNumber) ,that its data type is bit . now I want to insert data in to this column randomly in such a way that 80 percent of record (8 record) get 0 randomly and 20 percent (2 record) get 1.

For Example Like this:

Id RandomNumber
1 0
2 0
3 0
4 1
5 0
6 0
7 0
8 1
9 0
10 0



Aucun commentaire:

Enregistrer un commentaire