I want to create a Random Sample of a Database with multiple tables related to each other. This sample should have a permanence, should not expire after the session is completed.
In this post I would like to expose the way I plan to proceed and listen to comments and suggestions.
I will begin with the central table 'Customers' and extract a random sample from it and save it as a View. Then I will left join the 'Customers_sample' View with any other table linked to it using the primary Customers key ('Customer_id') and proceed in a likewise manner to create Views of Samples of all the other related tables.
To extract the random sample I will use the following code:
SELECT * FROM Customers
WHERE (ABS(CAST(
(BINARY_CHECKSUM(*) *
RAND()) as int)) % 100) < 10
Your advice will be appreciated.
Aucun commentaire:
Enregistrer un commentaire