SQL Dates Practice Problems: 430 Questions with Solutions
430 SQL dates practice problems with solutions: DATEDIFF, DATE ADD, DATE FORMAT, months, weeks and retention. Written in MySQL, judged on hidden datasets.
- Problems: 430
- By difficulty: 96 easy · 170 medium · 164 hard
- Dialect: MySQL
Practise SQL date functions in MySQL: DATEDIFF, DATE_ADD and DATE_SUB with INTERVAL, YEAR, MONTH and DATE_FORMAT, TIMESTAMPDIFF and grouping by day, week or month. The problems are the time questions analysts are asked — retention after seven days, orders per month, the gap between two events.
Easy SQL dates problems
- Train Name and Travel Year on Every Booking
- Average Selling Price of Each Canteen Item
- Canteen Items Sold on Each Day
- Daily Active Users in the 30 Days to 15 March
- Days the Air Quality Got Worse Than the Day Before
- Fixed Deposits Maturing in March 2025
- Library Loans Overdue on Audit Day
- Library Cards Expiring in March 2025
- Marketplace Orders per Month in 2024
- Fee Invoices Paid Late or Still Overdue
- Weekend Food Orders in March 2024
- Diamond and Master Players Who Went Quiet
- Daily Active Players From the Login Log
- Lab Reports Breaching the 24-Hour Turnaround
- Completed OPD Visits per Department in March 2025
- Medicine Batches Expiring Within 90 Days
- Employees Overdue for Probation Confirmation
- Late Punch-Ins per Employee in March 2025
- Work Anniversaries Coming Up in October 2025
- Machines Overdue for Calibration on Audit Day
- Solar Plant Monthly Generation in 2024
- Ad Campaigns Still Live at the Quarter Close
- Instagram Creator Deals Signed in Q3 2024
- Drivers Without a Single Completed Trip in March 2024
- Late-Night Ride Requests for the May Safety Audit
- Undelivered Shipments Past Their Promised Date
- Urgent Support Tickets Waiting More Than a Day
- Production Incidents Opened on a Weekend
- Maintenance Tickets Breaching the Seven-Day SLA
- Leases Ending Within the Next 30 Days
- Open Purchase Orders Past Their Promised Date
- March POS Bills by Day of the Week
- Annual Enterprise Accounts Signed Up in 2024
- Daily Active Users From the Event Log
- Free Trials Ending Within a Week
- Moderation Reports Filed on Weekends in March 2025
- Label Accounts Active, Dormant or Churned
- T20 League Fixtures Played on a Weekend in 2024
- Subscriptions Renewing in the Next Seven Days
- Prepaid Plans Expiring in the First Week of June
- August Data Usage by Telecom Circle
- Electricity Bills Paid After the Due Date
- Power Outages Lasting Four Hours or More
- Room Nights Sold per Hotel
- Flights Departing More Than an Hour Late
- Airbnb: Friday and Saturday Check-Ins per City
- Amazon: Lightning Deals That Sold Out Before Ending
- Amazon: Alexa Requests and Households by Device Family
- Amazon: EC2 Billable Seconds With the One-Minute Minimum
- Apple: AppleCare Claims Filed in a Device's First 30 Days
- Apple: App Store Apps Not Updated Since Mid-2023
- Dream11: Withdrawals That Missed the 24-Hour Payout Promise
- Dream11: Contests and Prize Pools per Sport in May 2025
- Dream11: Deposits Above a User's Own Monthly Limit
- Flipkart: Orders Placed Each Day of Big Billion Days
- Google: March Cloud Bill for Every Project
- Google: Chromebooks Not Synced in 90 Days
- Hotstar: Next-Day Views of Regional Serials
- LinkedIn: Invitations Pending for More Than 30 Days
- LinkedIn: Active Premium Members per Plan on Quarter End
- LinkedIn: Learning Course Completions per Category in Q1 2025
- Meta: Marketplace Listings Sold Within a Day
- Meta: Ad Accounts That Overspent Their September Limit
- Meta: Messenger Video Call Minutes by Day of the Week
- Meta: Moderation Reports Reviewed Past Their SLA
- Microsoft: Teams Meetings That Ran Past Their Booked Slot
- Microsoft: Products With Three or More Severity A Cases in March
- Myntra: Orders Placed in the EORS Insider Early-Access Hours
- Myntra: Most Common Return Reasons in 2024
- Myntra: Return Requests Raised After the Category's Window
- Myntra: M-Now Deliveries Inside the 30-Minute Promise by Store
- Ola: Wallets Topped Up Over ₹10,000 in May 2024
- Ola: Driver Licences Expiring Within 30 Days
- Ola: Scooters Due for Their First Free Service
- Paytm: February LPG Cylinder Bookings by Gas Provider
- Paytm: January FASTag Toll Spend for Each Vehicle
- Paytm: Tatkal Train Bookings Made in the First Five Minutes
- PhonePe: In-App Insurance Premium by Product Line in 2025
- PhonePe: Collect Requests Still Pending After Their Expiry
- Razorpay: Payment Links That Lapsed Without Payment
- Razorpay: Normal-Speed Refunds That Took Over a Week
- Spotify: Long-Form Podcast Episodes Released in 2024
- Spotify: Artists Who Released Nothing in 2024
- Spotify: Student Plans Due for Re-Verification
- Swiggy: Instamart Orders Delivered Within 10 Minutes
- Swiggy: Kitchens That Overshot the Promised Prep Time
- Uber: Uber One Trials Ending Without Auto-Renew
- Uber: Rider Cancellations That Earn a Late-Cancel Fee
- Uber: Cities With Two or More Critical Safety Reports
- Walmart: Active Walmart+ Members on 30 June by Plan
- Walmart: Associate Shifts Clocked Over Ten Hours
- Walmart: DC Trailers Dispatched Under 80% Full
- Zomato: Hygiene Certificates Expiring in July
- Zomato: Gold Members Yet to Use a Single Benefit
- Zomato: Feeding India Cities That Raised ₹50,000
- Zomato: Hyperpure Invoices Paid Late or Still Overdue
Medium SQL dates problems
- Share of Quiz Players Who Returned the Next Day
- Monthly Ticket Refund Report by Railway Zone
- Canteen Menu Prices on 15 March
- Cloud Kitchen Seven-Day Moving Average
- UPI Payments by Month and City
- Share of Customers Whose First Grocery Order Came Same Day
- UPI Success Rate by App and Month
- Borrowers With Repeatedly Overdue EMIs
- Credit Cards Over 30% Utilisation in September
- Branch Deposits Against the Previous Calendar Month
- Inoperative Accounts Under the Two-Year Rule
- Grievances Resolved Within the Seven-Day SLA
- Recurring Donors Across Three Months of 2024
- Monthly Library Issues by Genre
- Delivery SLA Breaches by Postal Zone
- Flash Sale Units Sold Inside the Sale Window
- Monthly GMV Against the Previous Calendar Month
- Customers Who Reordered Within 30 Days
- GST Split Into CGST, SGST and IGST by Seller
- Monthly Fee Collection by Payment Mode
- Late Coursework Uploads and Average Hours Late per Course
- Riders Missing the Delivery SLA in June 2024
- Peak-Hour Share of Orders by City
- Rider Login Hours and July Incentive Tier
- Month-Over-Month Delivered GMV Change by City
- Customers Whose Second Order Came Within a Week
- Ranked Queue Wait Time by Hour of Day
- Players Reported for Cheating by Three Reporters in a Month
- Whale Share of Monthly Store Revenue
- Guilds With Three Active Members in the Last Week
- Each Player's First Store Purchase After Sign-up
- Patients Readmitted Within 30 Days of Discharge
- Cashless Claims Settled per Insurer per Month
- Lab Tests Slower Than Their Usual Turnaround
- Ward Bed Occupancy on the Census Date
- Peak Arrival Hour in Emergency Each Day
- Employees Averaging Less Than Eight Hours a Day
- Average Days to Fill a Requisition by Department
- High Performers Due for a Promotion Review
- Monthly Attrition Rate in 2024
- Machines With Over Two Hours of Unplanned Downtime
- Late Work Order Rate by Line
- Machines Due for Preventive Maintenance by Quarter End
- Solar Generation Sharp Day-Over-Day Drops
- EV Charging Peak and Off-Peak Revenue
- Campaign Months That Overspent the Budget
- Email Open Rate by Hour of Send
- Weekly Leads by UTM Medium
- Month-over-Month Ad Spend Change by Channel
- Couriers Who Missed the Delivery SLA on Over 20% of May Drops
- Top-Earning Driver in Each City for Q1 2024
- Drivers Qualifying for City Trip Incentives
- Monthly Completed Trips, GMV and Average Fare
- Driver Idle Gaps Longer Than 90 Minutes
- First-Response SLA Breach Rate by Priority
- Monthly Change Failure Rate of Production Deploys
- Customers Contacting Support Again Within a Week
- Peak Ticket Hour for Each Day of the Week
- Vacancy Gaps Between Tenants of a Flat
- Monthly Rent Collection: On Time, Late and Unpaid
- Days From First Site Visit to Booking
- Co-Living Bed Occupancy by Property
- Each Broker's Best Month by Deal Value
- Supplier Average Lead Time in Days
- Cycle Count Shrinkage Value by Store and Month
- Store Revenue Against the Previous Calendar Month
- Slow-Moving SKUs Still Holding Stock
- Warehouse Transfers Still in Transit
- Days From Signup to First Captured Payment
- Monthly Paid Revenue and Its Change From Last Month
- Paid Accounts Dormant for Over 30 Days
- Power Users Active on Four or More Days a Month
- Monthly Active Users, New Versus Returning
- Creator Engagement Rate by Month
- Sharp Follower Drops Between Daily Snapshots
- Group Chats Silent for More Than 30 Days
- Share of Seats Booked Two Weeks Early for Each Match
- Monthly Fantasy Contest Entries and the Change From Last Month
- Monthly Active Viewers and Minutes per Viewer
- Listeners With a Song on Repeat
- Titles Licensed in Every Region on Launch Day
- Sign-Up Channels by First-Week Activation
- Monthly Subscription Revenue With a Running Total
- Units Consumed From Cumulative Meter Readings
- Monthly Recharge Revenue by Pack Type
- Busiest Calling Hour per Cell Tower
- Number Port Requests Breaching the 72-Hour SLA
- Prepaid Service Lapses Between Recharges
- Hotel Occupancy on New Year's Eve
- Average Daily Rate by Hotel and Month
- Waitlist Positions on a Train per Class
- Hotel Cancellation Refunds Under a Tiered Policy
- Double-Booked Hotel Rooms
- Loyalty Points Expiring for Inactive Members
- Airbnb: Host Response Rate Within 24 Hours
- Airbnb: Guests Who Came Back to the Same Host Within a Year
- Amazon: Echo Buyers Who Added a Smart Plug Within 60 Days
- Amazon: Prime Day Deals Not Below the 30-Day Low Price
- Apple: Daily Share of Checked-In Devices on iOS 18
- Apple: Genius Bar Repeat Visits Within 14 Days
- Apple: Apple Pay Monthly Volume Change by Country
- Apple: New and Cumulative Unique Apple Arcade Players by Day
- Dream11: Withdrawal Requests Made Before KYC Approval
- Flipkart: Refund SLA Breaches by Product Category
- Flipkart: Months Members Burned More SuperCoins Than Earned
- Flipkart: Products Rated Lower After Big Billion Days
- Flipkart: F-Assured Sellers Missing the 24-Hour Dispatch SLA
- Flipkart: Pay Later Bills Not Cleared by the Due Date
- Google: Play Installs Removed Within a Week
- Google: Searches Reformulated Within a Minute
- Google: Longest Heartbeat Gap of Each Nest Device
- Google: Meet Calls Where Guests Waited for a Late Host
- Hotstar: Accounts Streaming From Three Cities in a Day
- Hotstar: Subscriptions With No Play in Their First Week
- Hotstar: Final-Day Paid Sign-Ups by Hour With a Running Total
- LinkedIn: Members Whose Profile Views Doubled in May
- LinkedIn: Jobs Reposted Within 30 Days
- LinkedIn: Premium Free-Trial Conversion by Trial Month
- Meta: Ad Set Metrics Unpivoted Into Long Format
- Meta: Last-Click Attributed Revenue by Campaign
- Meta: Facebook Groups Where Every Admin Approved a Post
- Meta: WhatsApp Business Message Delivery Funnel
- Meta: Advertisers Whose Spend Fell Three Months Running
- Meta: Instagram Follow-Backs Within a Week
- Meta: Marketplace Listings Against the Same Month Last Year
- Microsoft: Azure Q1 Cost Split by Service Family per Month
- Microsoft: Xbox Players Who Unlocked Every Achievement in a Title
- Microsoft: Paid but Unassigned Microsoft 365 Seats on 30 June
- Microsoft: Days Between Windows Insider Flights per Channel
- Microsoft: Teams Daily Stickiness (DAU/MAU) in March 2025
- Myntra: Creator Store Commission for October 2024
- Myntra: Styles Marked Down by at Least 40% for EORS Day One
- Myntra: Delivered GMV by Indian Fiscal Year and Quarter
- Myntra: Monthly Net Revenue After Refunds in 2024
- Ola: Busiest Hour of the Day at Each Hypercharger
- Ola: Test Riders Who Bought Within 30 Days, per Centre
- Ola: Rentals Bill With Extra Kilometres and Minutes
- Ola: New Riders Who Took a Second Ride Within 7 Days
- Ola: OTA Update Adoption in Its First Week, by City
- Ola: Riders Whose Main Ride Moved From Auto to Cabs
- Paytm: Users Who Paid Electricity in Every Month of Q1 2025
- Paytm: Scratch Cards That Expired Unscratched
- Paytm: Busiest Day for Each EDC Card Machine
- Paytm: Flight Cancellation Refunds Under the Free Window
- Paytm: Merchant Days When QR Collections Fell by More Than Half
- PhonePe: Monthly P2P Versus P2M Payment Value in 2024
- PhonePe: Top District by Transaction Count in Each State, Q2 2025
- PhonePe: Motor Policy Renewal Rate by Expiry Month
- PhonePe: New Users Who Tried Three Products in Their First 30 Days
- PhonePe: Rewards Campaign Redemption Report on 1 April
- Spotify: Discover Weekly Save Rate per Listener
- Spotify: Free Listeners Who Hit the Hourly Skip Cap
- Swiggy: Swiggy One Plans That Paid for Themselves
- Swiggy: Longest Idle Gap in a Partner's Day
- Swiggy: Food Customers Who Later Tried Instamart
- Swiggy: Busiest Instamart Store per City Each Month
- Uber: Surge Share of Bengaluru Trips by Hour of Day
- Uber: Pickup ETA Accuracy by City
- Uber: Drivers Gone Quiet Before the Festive Rush
- Uber: Airport Queue Position When Each Driver Arrived
- Uber: Rider Referrals That Qualified for the Bonus
- Uber: Back-to-Back Trips Starting in the Last Drop Zone
- Walmart: Close-Then-Open Shifts With Under Ten Hours' Rest
- Walmart: Repeat Receiptless Returns Across Stores
- Walmart: Late Store Deliveries by Day of the Week
- Zomato: Gold Membership Renewal Rate by Plan
- Zomato: Cost per Order of Each Promoted Listing
- Zomato: Blinkit Stock-Outs Lasting a Day or More
- Zomato: Restaurants Buying From Hyperpure Every Month of Q1
- Zomato: Table Reservation No-Show Rate by Meal Slot
Hard SQL dates problems
- Rapid Repeated UPI Transfers: a Fraud Signal
- Savings Accounts Below the Minimum Average Balance
- UPI App New-User Retention in the Following Month
- Top Two PSP Handles by Monthly UPI Volume
- Days From Account Opening to a ₹1 Lakh Balance
- Wards With Complaint Streaks of Three Days or More
- Median Days to Close Service Requests by Department
- Donor Retention by First-Gift Year
- Auditorium Bookings That Clash Once Changeover Is Counted
- Shopping Sessions Abandoned After Add to Cart
- Monthly Buyer Cohort Retention
- Median Delivery Days per Courier Partner
- Longest Daily Selling Streak per Seller
- Overlapping Flash Sales on the Same Product
- Longest Daily Learning Streak of Each Learner
- Next-Month Retention of Learner Sign-up Cohorts
- Clashing Exam Slots in Students' Timetables
- Day Each Branch Crossed 50% Placement
- Next-Month Retention of First-Order Cohorts
- Double-Logged Rider Shifts That Overlap
- Dark Store Daily Orders, Zero Days Included
- Longest Daily Login Streak per Player
- Day-1 and Day-7 Retention by Signup Week
- Battle Pass Race to Tier 30, Season by Season
- ICU Over-Capacity Streaks
- Median Length of Stay by Ward
- OPD New-Patient Retention by Monthly Cohort
- Double-Booked Doctor Appointment Slots
- Daily Admissions With Quiet Days and a Running Total
- Overlapping Approved Leave Within a Team
- Unplanned Absence Streaks of Three Working Days
- 90- and 180-Day Retention of 2024 Hires by Quarter
- Merged Alarm Downtime per Machine
- Median EV Charging Session Length by City
- Solar Daily Output With Missing Days Filled
- Streaks of Three or More Overspent Days
- Ad-Click Sessions per Shopper
- Dark Days Inside Campaign Flight Dates
- Creators Booked by Two Rival Brands at Once
- Each Driver's Longest Streak of Active Days
- Rider App Sessions and Booking Conversion
- The Day Each Driver Hit the Monthly ₹10,000 Target
- Median Pickup-to-Drop Minutes in Each Delivery Zone
- Double-Booked Self-Drive Rental Cars
- Daily Sorting-Hub Backlog Including Days With None
- Total Outage Minutes per Service With Overlaps Merged
- Gaps in the On-Call Rota
- Repeat Contact Rate by First-Ticket Month
- Sessionise API Calls and Count Server Errors
- Median Time to Resolve Incidents by Severity
- Tenants Late on Rent Three Months Running
- Median Registered Rate per Sq Ft by Locality
- Double-Booked Beds in a Co-Living Space
- Occupied Flats on the First of Each Month
- Six-Month Renter Retention by Move-In Cohort
- Longest Consecutive Stock-Out Run per SKU
- Median Supplier Lead Time From Goods Inward
- Supplier On-Time-In-Full Rate by Order Quarter
- Daily Stock Carried Forward From the Last Count
- User Sessions From Thirty-Minute Event Gaps
- Monthly Signup Cohort Retention
- Longest Daily Usage Streak per User
- Month-End MRR From Subscription Periods
- Average Reply Time in Direct Messages
- Longest Daily Posting Streak per Creator
- First-Week Retention by Sign-Up Month
- App Sessions From the Event Stream
- Fantasy App Signup Cohorts Retained Into the Next Month
- Days Each Player Was Out Injured, Merging Overlapping Records
- Binge-Watch Runs of Three or More Episodes
- Longest Daily Listening Streak per Listener
- Next-Month Viewing Retention of Streaming Sign-Up Cohorts
- Accounts Streaming Past Their Screen Limit
- Free-Trial Conversion and Second-Month Funnel
- Daily Streams in an Album's First Week, Zero Days Included
- Longest Streak of Heavy Data Days
- Feeder Downtime After Merging Overlapping Outages
- Prepaid Recharge Next-Month Retention by Cohort
- Daily Network Drop Rate Including Silent Days
- Flights Delayed Three or More Days in a Row
- Peak In-House Guests per Hotel
- Repeat-Guest Retention Within 90 Days by Cohort
- Nightly Rooms Sold Calendar for the Holiday Season
- App Sessions That End in a Hotel Booking
- Date Each Frequent Flyer Qualified for Gold
- Airbnb: Longest Open Stretch on Each Listing's Calendar
- Airbnb: Collapse Nightly Prices Into Rate Periods
- Airbnb: Back-to-Back Stays Merged Into Trips
- Airbnb: Hosts With Three Cancellations Inside 30 Days
- Airbnb: Quote Stays From Nightly Prices and Discounts
- Airbnb: Attribute Each Booking to Its Last Search
- Amazon: First Day Each Seller Breached the 60-Day Order Defect Rate
- Amazon: Package Dwell Time at Each Facility Visit
- Amazon: Five-Star Review Bursts From Brand-New Accounts
- Amazon: Suggested Subscribe & Save Cadence From Reorder Gaps
- Apple: Subscription Billing Lapses Recovered in the Grace Period
- Apple: In-App Revenue at the Price in Effect on Each Day
- Apple: Apps Breaking Into Their Category's Top Three
- Apple: Apple Pay Rolling Seven-Day Fraud Rate
- Dream11: Withdrawals Right After a Deposit With No Play Between
- Dream11: Second-Paid-Contest Activation Rate by Signup Month
- Flipkart: Big Billion Days GMV by Sale Day Against Last Year
- Flipkart: Month-to-Month Sales Quartile Movement Matrix
- Flipkart: Sale-Acquired Buyers Who Came Back for the Next Sale
- Flipkart: First Day a Seller Logged Three Returns in Seven Days
- Google: YouTube Channels Eligible for the Partner Programme
- Google: Play Service Fee and the Purchase That Crossed the Tier
- Google: Prorated Workspace Seat-Days for June 2025
- Google: Median First-Reply Time in Gmail Support Threads
- Hotstar: Viewers Lost During Each Rain Delay
- Hotstar: Deduplicated Watch Minutes Across Overlapping Devices
- Hotstar: Stage Times of Slow Highlights Clips
- Hotstar: Subscribers Covered on Every Playoff Match Day
- LinkedIn: Applications Year over Year by Company and Quarter
- LinkedIn: Merge Overlapping Premium Periods Into Spans
- LinkedIn: Boomerang Hires in Members' Work History
- Meta: WhatsApp Business Conversation Windows
- Meta: Growth Accounting of Monthly Active Users
- Meta: Trending Reels Tags Split Out of Comma-Separated Lists
- Meta: The Day Each Campaign Exhausted Its Lifetime Budget
- Microsoft: Teams Attendees Present for at Least 75% of a Meeting
- Microsoft: Bing Search Sessions That Ended Without a Click
- Microsoft: Game Pass Win-Back Rate by Cancellation Month
- Myntra: EORS First-Time Buyers Who Ordered Again Within 90 Days
- Ola: Each Scooter's Opening and Closing Readings per Day
- Ola: Driver-Partner Activation and Retention by Approval Month
- Ola: Scooters Covered by a Care Plan on Each Month End
- Ola: First Fault Code After Each Software Install
- Ola: Service Tickets Breaching the 3-Working-Day SLA
- Paytm: Gold Buyers Whose Weighted Cost Beat the Simple Average
- Paytm Money: SIP Investor Retention Three Months Later by Cohort
- Paytm: Daily Seats Sold for Every Day of a Movie's Run
- Paytm: Merchant Loan Outstanding as of 31 January 2025
- Paytm: Spending Before and After Cashback for Each Campaign
- Paytm: Return Flights Booked Within Ten Days
- PhonePe: Users Paying Three New Payees Within One Hour
- PhonePe: Failed UPI Payments Recovered by a Retry, per Bank
- PhonePe: Merchants Earning Half Their Takings From Three Customers
- PhonePe: Three-Way Circular Transfers Within 24 Hours
- Razorpay: Payments Settled After Their T+N Working Day
- Razorpay: Merchants Whose Live Methods Differ From Their Request
- Razorpay: Diwali-Week Captured Volume Against Last Year's Diwali Week
- Razorpay: Merchants Whose Weekly Success Rate Fell 10+ Points
- Razorpay: Subscription Billing Cycles With No Charge Attempt
- Spotify: Artists Growing Year Over Year in Every Market
- Spotify: Family Plans That Ever Had Over Six Members at Once
- Spotify: Listeners Whose Top Genre Changed From Q1 to Q2
- Swiggy: Third Delivered Order of Each New Customer
- Swiggy: Restaurant Offline Minutes Within Opening Hours
- Swiggy: Kitchens Slowing Down Three Weeks Running
- Uber: Fleet Vehicles on Two Drivers' Shifts at Once
- Uber: Evening Hours Where Requests Outran Online Drivers
- Uber: Longest Surge Episode in Each Zone
- Uber: Freight Lane Rates Spiking Over the 28-Day Average
- Uber: Which Promo Gets Credit for a Rider's First Trip
- Walmart: Did the Rollback Lift Daily Unit Sales?
- Walmart: Walmart+ Membership Spells, Bridging Short Lapses
- Walmart: Median Minutes From Shelf Gap to Refill by Department
- Zomato: Live Menu Rebuilt From the Latest Approved Edits
- Zomato: Cuisine Gaps in Each Locality Worth Recruiting For
- Zomato: Restaurant Partner Anniversaries Falling in November
- Zomato: Progressive Commission on Each Restaurant's Monthly Sales
- Zomato: Orders Placed While the Restaurant Was Closed
- Zomato: Ratings Before and After a Hygiene Audit