1 / 8 · Book 15 · Your First SELECT -- Reading the Source of Truth · drill: interview Q&A⊞ allnext →Get the book →
1.13Exercises
Beginner:
- Write a SELECT query to find all users with the role 'admin'.
- Write a query to count how many users have
email_verified = false. - Write a query to find the most recently created user.
Intermediate:
- Write a query that finds users whose
updated_atequalscreated_at(never modified). - Write a Python test that creates a user via API and verifies the default role in the database.
- Write a query to find all soft-deleted users (deleted_at IS NOT NULL) created in the last 30 days.
Advanced:
- Write a verification query that returns rows ONLY if there is an inconsistency between the users table and user_profiles table (every user should have a profile).
- Write a comprehensive Python test fixture that provides both API client and database cursor, with automatic cleanup.
- Write a query that detects timestamps in the future or before the year 2020, across all timestamp columns in the users table.