Interview Query

Sample Time Series

7
Have you seen this question before?

Given a transactions table with date timestamps, sample every 4th row ordered by the date.

Example:

Input:

transactions table

Columns Type
id INTEGER
user_id INTEGER
created_at DATETIME
product_id INTEGER
quantity INTEGER

Output:

Columns Type
created_at DATETIME
product_id INTEGER
Next question: Commercial Break
.....
MySQL 8.0.17
Loading editor
Use Shift + Enter to run query