SQL & DataLearn SQL. Work with data.
Read a lesson, explore its examples in SQL and pandas, then solve the related problems.
Prerequisites guide your preparation; they do not block access to a lesson.
Put rows in the order the reader expects, break every tie on purpose, and hand back one page at a time.
Practice 10 problems 0 solved
- Five Priciest ListingsEasy
- Third Page of Newest ProductsEasy
- Three Lowest ScoresEasy
- Second Page of Search ResultsMedium
- Best Effective Price per ItemMedium
- Stable Leaderboard CutoffMedium
- Support Queue in Triage OrderMedium
- Feed Page After a CursorMedium
- How Many Result PagesMedium
- Second Page, Two per PageMedium
Cut, clean, count, and combine text with a handful of functions that compose into anything.
Practice 14 problems 0 solved
- Masked Card EndingsEasy
- Signups by Email DomainMedium
- Normalized Brand CountsMedium
- SKU Prefix AuditMedium
- Shipping Label LinesMedium
- Handles That Break the RulesMedium
- Signups by Area CodeMedium
- Split Full Names for the Badge PrinterMedium
- Initials from a Full NameMedium
- How Many Tags per PostMedium
- Title to URL SlugMedium
- Names Starting with a VowelMedium
- Letters Without SpacesMedium
- Alerts Carrying a SEV1 CodeMedium
Do arithmetic the way the database does it, and treat dates as values you can subtract, shift, and take apart.
Practice 13 problems 0 solved
- Attachment Sizes in Whole MegabytesEasy
- Which Quarter Each Sale Falls InEasy
- Hour of Each EventEasy
- Whole Dollars and Loose CentsMedium
- Days from Order to DeliveryMedium
- Quotes per MonthMedium
- Rate Change Percent, in Basis PointsMedium
- Minutes from Page to AcknowledgeMedium
- Renewals Due This QuarterMedium
- Weekend vs Weekday OrdersMedium
- Tenure in DaysMedium
- Round Cents to the Nearest DollarMedium
- Discount PercentageMedium
Duplicates, Median and Mode
Find what repeats, keep one of it, and summarise a column by its middle and its most common value.
Practice 5 problems 0 solved
- Duplicate Contact EmailsEasy
- First Signup per EmailMedium
- Most Common Complaint CategoryMedium
- Repeated TransactionsMedium
- Median Delivery Minutes per CarrierHard
Find what is missing from a sequence, what runs together, and what overlaps in time.
Practice 13 problems 0 solved
- Break in the Invoice SequenceMedium
- Double-Booked Meeting RoomsMedium
- Three Failed Checks in a RowMedium
- Coverage Lapses Between PoliciesMedium
- Lowest Free Short CodeMedium
- Deliveries Active at the Noon CutoverMedium
- Peak Simultaneous Streams per AccountHard
- Free Gift-Card Number RangesHard
- Double-Booked RoomsHard
- Longest Run of Consecutive NumbersHard
- How Many Separate StreaksHard
- Smallest Missing PositiveHard
- Three Busy Days in a RowHard
Window Functions I: Ranking and Top-N
Compute a value across a set of rows without collapsing them, then rank, pick the top few, or compare each row to its group.
Practice 17 problems 0 solved
- Number the LeaderboardEasy
- Revenue Rank Within CategoryMedium
- Top Two Spenders per RegionMedium
- Gap to the Department CeilingMedium
- Podium Places with Shared MedalsMedium
- Top Earner in Every Department, Ties KeptMedium
- Second-Fastest Lap per KartMedium
- Where the Tiebreak Actually MatteredMedium
- Global Top Three, Ties IncludedMedium
- Second-Highest Salary per DepartmentMedium
- Top Two Products per CategoryMedium
- Competition Ranking with GapsMedium
- Flag the Top Earner in Each DepartmentMedium
- Cheapest Product per CategoryMedium
- Podium Medals by RankMedium
- Runner-Up Bid, or NothingMedium
- Median Resolution Hours per TeamHard
Window Functions II: Running Values
Let each row see the rows before and after it: running totals, changes from the previous row, gaps to the next, and moving windows.
Practice 16 problems 0 solved
- Warmer Than the Day BeforeEasy
- Running Account BalanceMedium
- Day-over-Day Signup ChangeMedium
- Three-Day Moving Unit TotalMedium
- Share of Category RevenueMedium
- Drawdown from the Running PeakMedium
- Days Until the Next OrderMedium
- Sensor Drift Since First ReadingMedium
- Readings That Repeat the Previous OneMedium
- Flag Each Customer's First OrderMedium
- Days Since the Previous OrderMedium
- Running Count Within CategoryMedium
- Difference from the Category BaselineMedium
- Cumulative SignupsMedium
- Last Rider Under the Weight LimitMedium
- Longest Daily Usage StreakHard
Turn rows into columns and columns into rows, bucket values, fill blanks with zeros, and add the total line.
Practice 14 problems 0 solved
- Label Each Order's SizeEasy
- Web vs Store Revenue by RegionMedium
- Order Size BucketsMedium
- Quarterly Columns to RowsMedium
- Category Spend with a Total RowMedium
- Signup Grid: Plans Across, Regions DownMedium
- Device Specs from Attribute RowsMedium
- Regional Revenue with Zero-Filled BlanksMedium
- Checkout Funnel Drop-OffMedium
- Pass and Fail Counts per ExamMedium
- Score Spread per TeamMedium
- Rating Buckets per ProductMedium
- Unpivot Subject ScoresMedium
- Average Sale Price, Unsold IncludedMedium
Hierarchical and Recursive Queries
Walk trees of any depth, build paths, and generate the rows you do not have, with one recursive CTE shape.
Practice 14 problems 0 solved
- Weekly Signup Cohorts, Quiet Weeks IncludedMedium
- Ancestors of Category 7Medium
- Total Budget Under the CEOMedium
- Root, Inner, or LeafMedium
- Everyone Under the DirectorHard
- Escalation Depth per EmployeeHard
- Folder Sizes Including SubfoldersHard
- Sales Calendar with Zero DaysHard
- Approval Chain to the TopHard
- Total Screws in the Speaker BuildHard
- Category BreadcrumbsHard
- Pages Reachable from HomeHard
- Missing Ticket NumbersHard
- Total Reports per ManagerHard
Product Analytics Patterns
Rates, active users, retention, funnels, and churn: the handful of query shapes behind almost every product metric.
Practice 15 problems 0 solved
- Signup Activation RateMedium
- Click-Through Rate by CampaignMedium
- Monthly Active UsersMedium
- Power UsersMedium
- Repeat Purchase RateMedium
- View-to-Buy Conversion RateMedium
- Churned After JuneMedium
- New Users per DayMedium
- Session Bounce RateMedium
- Confirmed on the Second Day, Not the FirstHard
- Seven-Day Signup Retention by CohortHard
- Pages Your Friends LikeHard
- Bad-Experience Rate in the First 14 DaysHard
- Returned the Very Next DayHard
- Cancellation Rate for Trusted UsersHard
Insert, update, and delete rows safely: from literal values, from other tables, with conditions, and inside a transaction.
Lesson with worked examples · No dedicated problem set