# Billboard Top 100 Year End Table

Table: **billboard\_top\_100\_year\_end**

**Schema:**

|             |         |
| ----------- | ------- |
| year        | int     |
| year\_rank  | int     |
| group\_name | varchar |
| artist      | varchar |
| song\_name  | varchar |
| id          | int     |

**Preview:**

<table><thead><tr><th width="99">year</th><th width="106">year_rank</th><th width="137">group_name</th><th width="139">artist</th><th width="192">song_name</th><th>id</th></tr></thead><tbody><tr><td>1956</td><td>1</td><td>Elvis Presley</td><td>Elvis Presley</td><td>Heartbreak Hotel</td><td>1</td></tr><tr><td>1956</td><td>2</td><td>Elvis Presley</td><td>Elvis Presley</td><td>Don't Be Cruel</td><td>2</td></tr><tr><td>1956</td><td>3</td><td>Nelson Riddle</td><td>Nelson Riddle</td><td>Lisbon Antigua</td><td>3</td></tr><tr><td>1956</td><td>4</td><td>Platters</td><td>Platters</td><td>My Prayer</td><td>4</td></tr><tr><td>1956</td><td>5</td><td>Gogi Grant</td><td>Gogi Grant</td><td>The Wayward Wind</td><td>5</td></tr></tbody></table>

## **MEDIUM**

## Find the top 10 ranked songs in 2010

What were the top 10 ranked songs in 2010? Output the rank, group name, and song name but do not show the same song twice. Sort the result based on the year\_rank in ascending order.

{% embed url="<https://platform.stratascratch.com/coding/9650-find-the-top-10-ranked-songs-in-2010?code_type=1>" %}

```sql
SELECT DISTINCT year_rank, group_name, song_name
FROM billboard_top_100_year_end
WHERE year = 2010
ORDER BY year_rank
LIMIT 10;
```

## Top 10 Songs

Find the number of songs of each artist which were ranked among the top 10 over the years. Order the result based on the number of top 10 ranked songs in descending order.

{% embed url="<https://platform.stratascratch.com/coding/9743-top-10-songs?code_type=1>" %}

```sql
SELECT 
    artist, 
    COUNT(id) AS num_top10_songs
FROM billboard_top_100_year_end
WHERE year_rank <= 10
GROUP BY 1
ORDER BY COUNT(id) DESC;
```

## The Best Artist

Find the number of times an artist has been on the billboard top 100 in the past 20 years. Output the result alongside the artist's name and order records based on the founded count in descending order.

{% embed url="<https://platform.stratascratch.com/coding/9744-artist-of-the-decade?code_type=1>" %}

```sql
SELECT 
    artist, 
    COUNT(id) AS num_top10_songs 
FROM billboard_top_100_year_end
WHERE year >= (SELECT MAX(year) - 20 
                FROM billboard_top_100_year_end) 
GROUP BY 1 
ORDER BY COUNT(id) DESC;
```

## Find the top-ranked songs for the past 20 years.

Find all the songs that were top-ranked (at first position) at least once in the past 20 years

{% embed url="<https://platform.stratascratch.com/coding/10283-find-the-top-ranked-songs-for-the-past-30-years?code_type=1>" %}

```sql
SELECT DISTINCT song_name
FROM billboard_top_100_year_end
WHERE year_rank = 1 
AND year >= (SELECT MAX(year) - 20 FROM billboard_top_100_year_end);
```


---

# 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://dshub.gitbook.io/ds-hub/sql/sql-practice/popular-websites-for-sql-practice/stratascratch/spotify/billboard-top-100-year-end-table.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.
