You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Source : https://leetcode.com/problems/queries-quality-and-percentage/
Author : liuyubobobo
Time : 2022-04-25
Using SUM / COUNT to get percentages
SELECT
query_name,
ROUND(AVG(rating / position), 2) AS quality,
ROUND(SUM(rating <3) /COUNT(*) *100.0, 2) AS poor_query_percentage
FROM Queries
GROUP BY query_name
Using AVG only to get all the information
SELECT
query_name,
ROUND(AVG(rating / position), 2) AS quality,
ROUND(AVG(rating <3) *100.0, 2) AS poor_query_percentage
FROM Queries
GROUP BY query_name