SQL Project — One Beautiful Morning

Situation

Task

Data Source

1. From data source, run a query to show a summary below:

2. From data source, run a query to show a summary below:

3. Create a graph for summary no. 1

Action

1. From data source, run a query to show a summary below:

Query:

SELECT me.Brand AS 'Brand',
SUM(CASE WHEN MONTH(t.DateTRX) = 5 THEN 1 ELSE 0 END) AS 'Mei',
SUM(CASE WHEN MONTH(t.DateTRX) = 6 THEN 1 ELSE 0 END) AS 'Juni',
SUM(CASE WHEN MONTH(t.DateTRX) = 7 THEN 1 ELSE 0 END) AS 'Juli',
SUM(CASE WHEN MONTH(t.DateTRX) = 8 THEN 1 ELSE 0 END) AS 'Agustus'
FROM transactions AS t
INNER JOIN
master_enroll AS me
ON t.LocationTrx = me.ID
GROUP BY me.Brand
ORDER BY me.Brand DESC

2. From data source, run a query to show a summary below:

Query:

SELECT me.Brand_Level AS 'Brand Level',
COUNT(t.ID) AS 'Total Transactions',
COUNT(DISTINCT(t.MemberID)) AS 'Uniq Customer',
SUM(CAST(REPLACE(REPLACE(t.PointEarn, ',', ''), '-', '0') AS INT)) AS 'PointEarn',
SUM(CAST(REPLACE(REPLACE(t.PointBurn, ',', ''), '-', '0') AS INT)) AS 'PointBurn',
SUM(CAST(REPLACE(REPLACE(t.ValueBeforeTax, ',', ''), '-', '0') AS INT)) AS 'ValueBeforeTax',
SUM(CAST(REPLACE(REPLACE(t.ValueAfterTax, ',', ''), '-', '0') AS INT)) AS 'ValueAfterTax'
FROM transactions AS t
INNER JOIN
master_enroll AS me
ON t.LocationTrx = me.ID
GROUP BY me.Brand_Level
ORDER BY me.Brand_Level DESC

3. Create a graph for summary no. 1

Results

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store