mardi 19 mars 2019

How do I SQL Randomize each column individualy

so let's say my table looks like this.

Input: Table Person
ID | first_name | last_name | age | gender
1  | Robert     | Müller    | 34  | m
2  | Jannis     | Fischer   | 19  | m
3  | Monika     | Schmid    | 54  | f

The purpose is to "create" data with the table itself. I want to randomize centraint columns of my table and put them back together.

I want to randomize first_name with gender that they will always be the same together and last_name and age can be randomized by their columns.

Output: Table Person

ID | first_name | last_name | age | gender
1  | Robert     | Schmid    |  34 | m
2  | Monika     | Müller    |  54 | f
3  | Jannis     | Fischer   |  19 | m

I tried to Join two select statements but this didn't really work.

I could be something like this:

Select ID, first_name, gender From Person TABLESAMPLE SYSTEM(10);

UNION

Select ID, last_name, age From Person TABLESAMPLE SYSTEM(10);

Thanks for you help!




Aucun commentaire:

Enregistrer un commentaire