Leetcode Problem 2205. The Number of Users That Are Eligible for Discount

2205. The Number of Users That Are Eligible for Discount

Leetcode Solutions

Counting Distinct Users with Eligible Purchases

  1. Start by creating a MySQL function getUserIDs that accepts three parameters: startDate, endDate, and minAmount.
  2. In the function, write a SQL query that selects the count of distinct user_id from the Purchases table.
  3. Apply a WHERE clause to filter the results based on the time_stamp being between startDate and endDate and the amount being greater than or equal to minAmount.
  4. Return the result of the query, which is the count of distinct users who are eligible for a discount.

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

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...