Leetcode Problem 2230. The Users That Are Eligible for Discount

2230. The Users That Are Eligible for Discount

Leetcode Solutions

Filtering and Aggregating Purchase Data

  1. Begin the MySQL procedure with the given startDate, endDate, and minAmount parameters.
  2. Write a SELECT query to fetch distinct user_ids from the Purchases table.
  3. Apply a WHERE clause to filter records where time_stamp is greater than or equal to startDate and less than or equal to endDate.
  4. Further filter records where amount is greater than or equal to minAmount.
  5. Order the result by user_id to get the list of eligible users in ascending order.
  6. End the procedure.

erDiagram
    Purchases {
        int user_id
        datetime time_stamp
        int amount
        user_id time_stamp PK
    }

Using DATE() Function for Date Range Filtering

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...