I want to randomly populate a column in my table with the following values: Available, On Hold, Partial Downpayment, Sold/Unavailable, Token
I have tried using the following command but it populates the entire column with the first value it gets.
update mytable
set sold_status = (select (array['Available', 'On Hold', 'Partial Downpayment', 'Sold/Unavailable', 'Token Recieved'])[floor(random() * 5 + 1)])
I know how to achieve this with a programming language, but I would prefer a PostgreSQL query to achive this.
Aucun commentaire:
Enregistrer un commentaire