Skip to content

Commit 52254a2

Browse files
committed
Section 02 : Basic Agg : part 02 - P5 and P6
1 parent d419331 commit 52254a2

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
SELECT
2+
query_name,
3+
ROUND(AVG(CAST(rating AS DECIMAL) / position), 2) AS quality,
4+
ROUND((SUM(CASE WHEN rating < 3 THEN 1 ELSE 0 END) / COUNT(*)) * 100, 2) AS poor_query_percentage
5+
FROM
6+
Queries
7+
WHERE
8+
query_name IS NOT NULL
9+
GROUP BY
10+
query_name;
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT DATE_FORMAT(trans_date, '%Y-%m') AS month,
2+
country,
3+
COUNT(id) AS trans_count,
4+
SUM(CASE WHEN state = 'approved' THEN 1 ELSE 0 END) AS approved_count,
5+
SUM(amount) AS trans_total_amount,
6+
SUM(CASE WHEN state = 'approved' THEN amount ELSE 0 END) AS approved_total_amount
7+
FROM Transactions
8+
GROUP BY month, country

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy