SQL Quest › SQL Interview Questions › Date Functions

Weekend Logins

EasyFreeQuerying BasicsDate Functions

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_idcustomer_idlogin_at
112024-03-01 08:12:00
212024-03-02 09:40:00
342024-03-01 18:05:00

Expected output: 13 rows — 7 on Saturdays, 6 on Sundays

Hint

SQLite's date formatter can return the day of the week as a number. In that numbering the week starts on Sunday at 0 and ends on Saturday at 6, so a weekend day is one of those two values. Filter on it in WHERE.

Concepts

SELECT WHERE Date Functions strftime IN

Practise the topic: SQL practice questions · Date function practice

Read the concept: SQL running total

Related questions

Pre-1900 BanksEasy · Free2025 SalesEasy · FreeHires per YearEasy · FreeEmployee Tenure BandsMedium · FreeQuarterly Hiring Cohort ReportMedium · FreeMonthly Order TrendsMedium · Free

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