Tuesday, 17 September 2013

Best way to use Rand() when creating dummy data

Best way to use Rand() when creating dummy data

I'm making up some dummy data for some tables. For columns that are ints
this is easy enough. I have a few columns that are just enums, and I'm
trying to figure out how to randomize them. I'm trying to replicate this
kind of logic, but for SQL
CASE RAND()
WHEN BETWEEN (0,.3) THEN 'A'
WHEN BETWEEN (.31, .6) THEN 'B'
WHEN BETWEEN (.61, 1) THEN 'C'
What is the correct way to actually do this? I assume there's a much
better way, but I have very limited SQL experience.

No comments:

Post a Comment