
In 8.sql, write a SQL query that lists the names of the songs that feature other artists. You should not make any assumptions about what Drake’s artist_id is. In 7.sql, write a SQL query that returns the average energy of songs that are by Drake.
You should not make any assumptions about what Post Malone’s artist_id is. In 6.sql, write a SQL query that lists the names of songs that are by Post Malone. Your query should output a table with a single column and a single row containing the average energy. In 5.sql, write a SQL query that returns the average energy of all the songs. In 4.sql, write a SQL query that lists the names of any songs that have danceability, energy, and valence greater than 0.75. In 3.sql, write a SQL query to list the names of the top 5 longest songs, in descending order of length. In 2.sql, write a SQL query to list the names of all songs in increasing order of tempo. Your query should output a table with a single column for the name of each song. In 1.sql, write a SQL query to list the names of all songs in the database. Finally, each query should return only the data necessary to answer the question: if the problem only asks you to output the names of songs, for example, then your query should not also output each song’s tempo. You should not assume anything about the ids of any particular songs or artists: your queries should be accurate even if the id of any particular song or person were different. Your response must take the form of a single SQL query, though you may nest other queries inside of your query.
Implementation Detailsįor each of the following problems, you should write a single SQL query that outputs the results specified by each problem. The challenge ahead of you is to write SQL queries to answer a variety of different questions by selecting data from one or more of these tables.
Notice, too, that every song has a name, an artist_id (corresponding to the id of the artist of the song), as well as values for the danceability, energy, key, loudness, speechiness (presence of spoken words in a track), valence, tempo, and duration of the song (measured in milliseconds). Notice that every artist has an id and a name. By examining those statements, you can identify the columns present in each table. This will output the CREATE TABLE statements that were used to generate each of the tables in the database. In a terminal window, run sqlite3 songs.db so that you can begin executing queries on the database.įirst, when sqlite3 prompts you to provide a query, type. This dataset contains the top 100 streamed songs on Spotify in 2018. Provided to you is a file called songs.db, a SQLite database that stores data from Spotify about songs and their artists. If you run into any trouble, follow these same steps again and see if you can determine where you went wrong! Understanding