# A tibble: 4 × 5
Name sex age height weight
<chr> <chr> <dbl> <dbl> <dbl>
1 A Dijiang M 24 180 80
2 A Lamusi M 23 170 60
3 Christine Jacoba Aaftink F 21 185 82
4 Per Knut Aaland M 31 188 75
# A tibble: 4 × 6
Name sex age height weight bmi
<chr> <chr> <dbl> <dbl> <dbl> <dbl>
1 A Dijiang M 24 180 80 24.7
2 A Lamusi M 23 170 60 20.8
3 Christine Jacoba Aaftink F 21 185 82 24.0
4 Per Knut Aaland M 31 188 75 21.2
SELECT*, weight /POWER((height/100),2) AS bmi FROM df;
4 records
Name
sex
age
height
weight
bmi
A Dijiang
M
24
180
80
24.69136
A Lamusi
M
23
170
60
20.76125
Christine Jacoba Aaftink
F
21
185
82
23.95909
Per Knut Aaland
M
31
188
75
21.22001
1. SUM
The SUM() formula performs addition on selected cells. It works on cells containing numerical values and requires two or more cells.
In our case, we will be applying the SUM formula to a range of cells from C2 to C5 and storing the result on C6. It will add 24, 23, 21, and 31. You can also apply this formula to multiple columns.
The MIN() formula requires a range of cells, and it returns the minimum value. For example, we want to display the minimum weight among all athletes on the E6 cell. The MIN formula will search for the minimum value and show 60.
# A tibble: 4 × 6
Name sex age height weight age_sex
<chr> <chr> <dbl> <dbl> <dbl> <chr>
1 A Dijiang M 24 180 80 24M
2 A Lamusi M 23 170 60 23M
3 Christine Jacoba Aaftink F 21 185 82 21F
4 Per Knut Aaland M 31 188 75 31M
jOINING TABLES
df
# A tibble: 4 × 5
Name sex age height weight
<chr> <chr> <dbl> <dbl> <dbl>
1 A Dijiang M 24 180 80
2 A Lamusi M 23 170 60
3 Christine Jacoba Aaftink F 21 185 82
4 Per Knut Aaland M 31 188 75
df2
# A tibble: 5 × 2
Name country
<chr> <chr>
1 A Dijiang China
2 A Lamusi Ghana
3 Christine Jacoba Aaftink Zimbabwe
4 Per Knut Aaland South Africa
5 Bongani USA
# A tibble: 4 × 6
Name sex age height weight country
<chr> <chr> <dbl> <dbl> <dbl> <chr>
1 A Dijiang M 24 180 80 China
2 A Lamusi M 23 170 60 Ghana
3 Christine Jacoba Aaftink F 21 185 82 Zimbabwe
4 Per Knut Aaland M 31 188 75 South Africa
SELECT d1.Name,d1.sex,d1.age,d1.height,d1.weight,d2.country FROM df AS d1LEFTJOIN df2 AS d2ON d1.Name = d2.Name;