Interview Query

Random SQL Sample

Start Timer

0:00:00

Upvote
8
Downvote
Save question
Mark as completed
View comments (56)
Next question

Let’s say we have a table with an id and name fields. The table holds over 100 million rows and we want to sample a random row in the table without throttling the database.

Write a query to randomly sample a row from this table.

Input:

big_table table

Columns Type
id INTEGER
name VARCHAR
.
.
.
.
.


Comments

Loading comments