1322. Ads Performance

https://leetcode.com/problems/ads-performance

Description

Table: Ads

+---------------+---------+
| Column Name   | Type    |
+---------------+---------+
| ad\_id         | int     |
| user\_id       | int     |
| action        | enum    |
+---------------+---------+
(ad\_id, user\_id) is the primary key for this table.
Each row of this table contains the ID of an Ad, the ID of a user and the action taken by this user regarding this Ad.
The action column is an ENUM type of ('Clicked', 'Viewed', 'Ignored').

A company is running Ads and wants to calculate the performance of each Ad.

Performance of the Ad is measured using Click-Through Rate (CTR) where:

Write an SQL query to find the ctr of each Ad.

Round ctr to 2 decimal points. Order the result table by ctr in descending order and by ad_id in ascending order in case of a tie.

The query result format is in the following example:

ac

Last updated

Was this helpful?