Skip to content

Commit d820fcf

Browse files
committed
islam updated aggregate functions #[6,8]
1 parent d542c1e commit d820fcf

File tree

2 files changed

+12
-7
lines changed
  • Basic Aggregate Functions

2 files changed

+12
-7
lines changed

Basic Aggregate Functions/06 -Monthly Transactions I/README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@ Return the result table in any order.
3131
</details>
3232
<details>
3333
<summary>Hint#5</summary>
34+
<p>
35+
The <code>DATE_FORMAT(date , format)</code> function formats a date as specified.
36+
</p>
37+
</details>
38+
<details>
39+
<summary>Hint#6</summary>
3440
<p>Use <code>GROUP BY</code> clause to group a set of rows into a set of summary rows</p>
3541
</details>
36-
3742
</details>
3843

3944
<details>
@@ -64,7 +69,7 @@ Return the result table in any order.
6469

6570

6671
```sql
67-
SELECT
72+
SELECT
6873
DATE_FORMAT(trans_date, '%Y-%m') AS month,
6974
country,
7075
COUNT(state) AS trans_count,
@@ -75,9 +80,9 @@ Return the result table in any order.
7580
SUM(
7681
CASE WHEN state = 'approved' THEN amount ELSE 0 END
7782
) AS approved_total_amount
78-
FROM
83+
FROM
7984
Transactions
80-
GROUP BY
85+
GROUP BY
8186
month,
8287
country
8388

Basic Aggregate Functions/08 -Game Play Analysis IV/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<details>
1818
<summary>Hint#2</summary>
1919
<p>
20-
Try use <code>WITH</code> clause. It will help you to define a temporary data set. It will make your life easier.
20+
Try using <code>WITH</code> clause. It will help you to define a temporary data set. It will make your life easier.
2121
</p>
2222
</details>
2323
<details>
@@ -29,7 +29,7 @@
2929
<details>
3030
<summary>Hint#4</summary>
3131
<p>
32-
Try use <code>window function</code>.
32+
Try using <code>window function</code>.
3333
</p>
3434
</details>
3535

@@ -67,7 +67,7 @@ Then when we find a player logged in the next day of this day we should put this
6767
<li>
6868
We will filter this table according to our condition <code>(event_date and first_login are consecutive days)</code>.
6969
<br>
70-
We can use <code>DATE_SUB()</code> function to subtract a given duration from <code>event_date</code> As follows<br> <code>DATE_SUB(event_date, INTERVAL 1 DAY) = first_login</code>
70+
We can use <code>DATE_SUB()</code> function to subtract a given interval (e.g, a year , a month , ...) from <code>event_date</code> As follows<br> <code>DATE_SUB(event_date, INTERVAL 1 DAY) = first_login</code>
7171
</li>
7272
<li>
7373
Finally, divide the player that satisfies the condition by the total number of player that we can calculate as a <code>subquery</code> then round the result using <code>ROUND()</code>function to round the result.

0 commit comments

Comments
 (0)