SQL Quest › SQL Interview Questions › Date Functions
Weekend Logins
The support team is deciding whether to staff weekends. They want every login that happened on a Saturday or a Sunday in March 2024.
Show exactly these 3 columns: login_id, customer_id and login_at. Order by login_at, then login_id.
login_at is a timestamp (2024-03-02 09:40:00); the table does not store the day of the week, so you have to work it out from the date. Check how your day numbering counts Sunday before you filter on it.
Solve it in the browser editor →
Runs on SQLite in your browser, graded against the expected result, no signup. A wrong answer gets a diagnosis, not just "incorrect". Free accounts get 10 free challenge solves, and this can be one of them.
Schema
logins
| login_id | customer_id | login_at |
|---|---|---|
| 1 | 1 | 2024-03-01 08:12:00 |
| 2 | 1 | 2024-03-02 09:40:00 |
| 3 | 4 | 2024-03-01 18:05:00 |
Expected output: 13 rows — 7 on Saturdays, 6 on Sundays
Hint
Concepts
SELECT WHERE Date Functions strftime IN
Practise the topic: SQL practice questions · Date function practice
Read the concept: SQL running total
Related questions
Where would this cost you points in an interview?
Ten questions, no signup: a Skillmap across nine SQL skills and the one to fix first.
Take the readiness test