1. Data Analyst
By: Dila Triarini
Practice SQL for
Data Analysis
JOIN THE BEST UPSKILLING COMMUNITY
WITH ME at myskill.id/bootcamp
FULLSTACK INTENSIVE BOOTCAMP
MINI PORTOFOLIO
2. #RintisKarirImpian
Course Summary
Aggregate Functions
Aggregate functions compute a single result from a set of input values.
Aggregate functions Description Syntax
avg(expression)
the average (arithmetic mean) of all
non-null input values
SELECT AVG(column_name) FROM table_name
count(expression)
number of input rows for which the
value of expression is not null
SELECT COUNT(column_name) FROM table_name
DISTINCT clause can be used with the
COUNT function to count only
unique/distinct values of a table
SELECT COUNT(DISTINCT column_name) FROM
table_name
max(expression)
maximum value of expression across
all non-null input values
SELECT MAX(column_name) FROM table_name
min(expression)
Minimum value of expression across
all non-null input values
SELECT MIN(column_name) FROM table_name
sum(expression)
sum of expression across all non-null
input values
SELECT SUM(column_name) FROM table_name
3. #RintisKarirImpian
Course Summary
GROUP BY Clause
The PostgreSQL GROUP BY clause is used to divide rows returned by SELECT statement into different
groups.(https://www.geeksforgeeks.org/postgresql-group-by-clause/) .
Aggregate functions are commonly combined with GROUP BY to group/categorized data based on one or more rows
Syntax Example
SELECT
column_1,
column_2,
computing_function(column_3)
FROM
table_name
GROUP BY
column_1,
column_2;
4. #RintisKarirImpian
Course Summary
HAVING Clause
The HAVING clause specifies a search condition for a group or an aggregate. The HAVING clause is often used with the
GROUP BY clause to filter groups or aggregates based on a specified condition
(https://www.postgresqltutorial.com/postgresql-tutorial/postgresql-having/).
Syntax Example
SELECT
column1,
aggregate_function (column2)
FROM
table_name
GROUP BY
column1
HAVING
condition;
6. #RintisKarirImpian
Case Study
3. Consumer named Joel Eaton ask for transaction recap related to product name and its quantity
which he have bought in Tokopaedi. Please create the transaction recap!
8. #RintisKarirImpian
Case Study
2. You need to give a promotion to 100 individual consumers (segment = ‘Consumer’) with the highest order average.
Please create the list of those consumer!
11. #RintisKarirImpian
Case Study
1. [tokopaedi] Please create list of consumer with average spending per transaction is higher
than average spending all consumer!
There are 291 customer with average spending per
transaction higher than the average spending all
consumer
12. Follow me!
Instagram : dilatriarini
Twitter : dilatriarini
LinkedIn : Dila Triarini
Bootcamp Data Analysis
by @myskill.id