Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add sql solution to lc problem: No.1322 #1815

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion solution/1300-1399/1322.Ads Performance/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,23 @@ SELECT
WHEN action = 'Viewed' THEN 0
ELSE NULL
END) * 100, 2), 0) AS ctr
FROM ads
FROM Ads
GROUP BY ad_id
ORDER BY ctr DESC,
ad_id ASC;
```

```sql
SELECT ad_id,
ROUND(
IFNULL(
SUM(action='Clicked') / SUM(action IN ('Clicked', 'Viewed')) * 100
, 0)
, 2)
AS ctr
FROM Ads
GROUP BY ad_id
ORDER BY 2 DESC, 1;
```

<!-- tabs:end -->
15 changes: 14 additions & 1 deletion solution/1300-1399/1322.Ads Performance/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,23 @@ SELECT
WHEN action = 'Viewed' THEN 0
ELSE NULL
END) * 100, 2), 0) AS ctr
FROM ads
FROM Ads
GROUP BY ad_id
ORDER BY ctr DESC,
ad_id ASC;
```

```sql
SELECT ad_id,
ROUND(
IFNULL(
SUM(action='Clicked') / SUM(action IN ('Clicked', 'Viewed')) * 100
, 0)
, 2)
AS ctr
FROM Ads
GROUP BY ad_id
ORDER BY 2 DESC, 1;
```

<!-- tabs:end -->
2 changes: 1 addition & 1 deletion solution/1300-1399/1322.Ads Performance/Solution.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ SELECT
),
0
) AS ctr
FROM ads
FROM Ads
GROUP BY ad_id
ORDER BY ctr DESC, ad_id ASC;