Skip to content

Commit 7bbca85

Browse files
Update ratio_to_report.md
1 parent 5123e6f commit 7bbca85

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

ratio_to_report.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Calculating percentages using RATIO_TO_REPORT
22

3-
RATIO_TO_REPORT Window function can be used to calculate percentage of the entire dataset or partitioned data.
3+
`RATIO_TO_REPORT` Window function can be used to calculate percentage of the entire dataset or partitioned data.
44

55
## An illustrative example
66

@@ -19,7 +19,7 @@ from soccer_players
1919

2020
Our data is about a soccer game where each row represents a player id, with columns for id, their team, and how many goals they have scored.
2121

22-
If we wanted to work out what percentage of all goal each player has scored, we can use ratio_to_report() window function as following:
22+
If we wanted to work out what percentage of all goal each player has scored, we can use `ratio_to_report()` window function as following:
2323

2424
```sql
2525
select
@@ -35,12 +35,13 @@ order by team, position;
3535
![Copy of Copy of Copy of favicon](https://github.com/user-attachments/assets/c0219bc2-6030-4fcb-a34e-c8523c48d07c)
3636

3737

38-
The over() in the query above tells the database to expand the ‘window’ in which the ratio_to_report() operates to the whole dataset.
38+
The `over()` in the query above tells the database to expand the _window_ in which the `ratio_to_report()` operates to the whole dataset.
3939

40-
The ratio_to_report() window function takes an expression (usually a column) as input and calculates the ratio of that expression to the window that is defined (in this case, the whole dataset).
41-
Using ratio_to_report() to Calculate Partitioned Percentages
40+
The `ratio_to_report()` window function takes an expression (usually a column) as input and calculates the ratio of that expression to the window that is defined (in this case, the whole dataset).
4241

43-
Let’s say we were not only interested in each players overall contribution to goals, but also their contribution to goals for their specific team. We can then add a partition by to the window:
42+
## Using ratio_to_report() to Calculate Partitioned Percentages
43+
44+
Let’s say we were not only interested in each players overall contribution to goals, but also their contribution to goals for their specific team. We can then add a partition by to the _window_:
4445

4546
```sql
4647
select
@@ -54,3 +55,14 @@ order by team, position;
5455
```
5556

5657
![Copy of favicon](https://github.com/user-attachments/assets/29fa93bc-61d8-436a-8d92-fc539fdbd243)
58+
59+
# See also:
60+
<ul id="recent-articles">
61+
{% for page in site.pages %}
62+
{% if page.title contains "RATIO_TO_REPORT" %}
63+
<li>
64+
<a href="{{ page.url | relative_url }}">{{ page.title | escape }}</a>
65+
</li>
66+
{% endif %}
67+
{% endfor %}
68+
</ul>

0 commit comments

Comments
 (0)