Step 1: Select rows where the 'silver' column is equal to 1 and the 'gold' column is equal to 0.
rank |
nation |
gold |
silver |
bronze |
total |
1 |
soviet union |
3 |
2 |
1 |
6 |
2 |
united states |
3 |
0 |
1 |
4 |
3 |
brazil |
2 |
3 |
0 |
5 |
4 |
russia |
1 |
1 |
2 |
4 |
5 |
japan |
1 |
1 |
1 |
3 |
6 |
netherlands |
1 |
1 |
0 |
2 |
7 |
yugoslavia |
1 |
0 |
1 |
2 |
8 |
poland |
1 |
0 |
0 |
1 |
9 |
italy |
0 |
2 |
3 |
5 |
10 |
czechoslovakia |
0 |
1 |
1 |
2 |
11 |
bulgaria |
0 |
1 |
0 |
1 |
11 |
east germany |
0 |
1 |
0 |
1 |
13 |
argentina |
0 |
0 |
1 |
1 |
13 |
cuba |
0 |
0 |
1 |
1 |
13 |
romania |
0 |
0 |
1 |
1 |
Step 2: Extract the sum of the 'total' column for the selected rows and add a column 'total_medals' to the existing table.
rank |
nation |
gold |
silver |
bronze |
total |
10 |
czechoslovakia |
0 |
1 |
1 |
2 |
11 |
bulgaria |
0 |
1 |
0 |
1 |
11 |
east germany |
0 |
1 |
0 |
1 |
Step 3: Select rows where 'total_medals' is greater than 2.
rank |
nation |
gold |
silver |
bronze |
total |
total_medals |
10 |
czechoslovakia |
0 |
1 |
1 |
2 |
4 |
11 |
bulgaria |
0 |
1 |
0 |
1 |
4 |
11 |
east germany |
0 |
1 |
0 |
1 |
4 |
Step 4: Use a `CASE` statement to return TRUE if the number of rows is greater than or equal to 1, otherwise return FALSE.
rank |
nation |
gold |
silver |
bronze |
total |
total_medals |
10 |
czechoslovakia |
0 |
1 |
1 |
2 |
4 |
11 |
bulgaria |
0 |
1 |
0 |
1 |
4 |
11 |
east germany |
0 |
1 |
0 |
1 |
4 |