Leetcode Problem 1934. Confirmation Rate

1934. Confirmation Rate

Leetcode Solutions

Calculating Confirmation Rate Using Conditional Aggregation

  1. Perform a LEFT JOIN between the Signups and Confirmations tables on the user_id column.
  2. Use the AVG function with a conditional statement inside to calculate the confirmation rate. The condition checks if the action is 'confirmed' and assigns a value of 1, otherwise 0.
  3. Group the results by user_id to calculate the confirmation rate for each user.
  4. Use the ROUND function to round the confirmation rate to two decimal places.
  5. Select the user_id and the calculated confirmation_rate for the final output.

erDiagram
    Signups {
        int user_id PK
        datetime time_stamp
    }
    Confirmations {
        int user_id PK
        datetime time_stamp PK
        ENUM action
        Signups_user_id FK
    }

Using Subqueries to Calculate Confirmation Rate

Ask Question

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

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...