# 1783. Grand Slam Titles

<https://leetcode.com/problems/grand-slam-titles>

## Description

Table: `Players`

```

+----------------+---------+
| Column Name    | Type    |
+----------------+---------+
| player\_id      | int     |
| player\_name    | varchar |
+----------------+---------+
player\_id is the primary key for this table.
Each row in this table contains the name and the ID of a tennis player.
```

Table: `Championships`

```

+---------------+---------+
| Column Name   | Type    |
+---------------+---------+
| year          | int     |
| Wimbledon     | int     |
| Fr\_open       | int     |
| US\_open       | int     |
| Au\_open       | int     |
+---------------+---------+
year is the primary key for this table.
Each row of this table containts the IDs of the players who won one each tennis tournament of the grand slam.
```

Write an SQL query to report the number of grand slam tournaments won by each player. Do not include the players who did not win any tournament.

Return the result table in **any order**.

The query result format is in the following example:

```

Players table:
+-----------+-------------+
| player\_id | player\_name |
+-----------+-------------+
| 1         | Nadal       |
| 2         | Federer     |
| 3         | Novak       |
+-----------+-------------+

Championships table:
+------+-----------+---------+---------+---------+
| year | Wimbledon | Fr\_open | US\_open | Au\_open |
+------+-----------+---------+---------+---------+
| 2018 | 1         | 1       | 1       | 1       |
| 2019 | 1         | 1       | 2       | 2       |
| 2020 | 2         | 1       | 2       | 2       |
+------+-----------+---------+---------+---------+

Result table:
+-----------+-------------+-------------------+
| player\_id | player\_name | grand\_slams\_count |
+-----------+-------------+-------------------+
| 2         | Federer     | 5                 |
| 1         | Nadal       | 7                 |
+-----------+-------------+-------------------+

Player 1 (Nadal) won 7 titles: Wimbledon (2018, 2019), Fr\_open (2018, 2019, 2020), US\_open (2018), and Au\_open (2018).
Player 2 (Federer) won 5 titles: Wimbledon (2020), US\_open (2019, 2020), and Au\_open (2019, 2020).
Player 3 (Novak) did not win anything, we did not include them in the result table.
```

## ac

```java
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jaywin.gitbook.io/leetcode/solutions/1783-grand-slam-titles.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
