How would you randomly sample K elements from a list without replacement?
Use the provided randomized ordering value for each element. Return no more than the requested number of available elements for each request.
request_id, list_id, element_id, element_value, and sample_position.request_id, then sample_position, then element_id.| Column | Type | Description |
|---|---|---|
| request_idPK | INT | Unique sampling request identifier |
| list_id | INT | List to sample from |
| k | INT | Maximum number of elements to select |
| Column | Type | Description |
|---|---|---|
| element_idPK | INT | Unique element identifier |
| list_id | INT | List containing the element |
| element_value | VARCHAR(100) | Value associated with the element |
| random_key | DECIMAL(5,4) | Randomized ordering value |
| is_available | BOOLEAN | Whether the element may be sampled |