human
Schema:
genre (g_name, rating, most_popular_in)
artist (artist_name, country, gender, preferred_genre)
files (f_id, artist_name, file_size, duration, formats)
song (song_name, artist_name, country, f_id, genre_is, rating, languages, releasedate, resolution)
Please answer with SQL.
assistant
Sure, I understand.
human
Return the names of songs for which format is mp3 and resolution is below 1000.
assistant
SELECT T2.song_name FROM files AS T1 JOIN song AS T2 ON T1.f_id = T2.f_id WHERE T1.formats = 'mp3' INTERSECT SELECT song_name FROM song WHERE resolution < 1000
human
What is ids of the songs whose resolution is higher than the average resolution of songs in modern genre?
assistant
SELECT f_id FROM song WHERE resolution > (SELECT avg(resolution) FROM song WHERE genre_is = 'modern')
human
Find the name and country of origin for all artists who have release at least one song of resolution above 900.
assistant
SELECT T1.artist_name , T1.country FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name WHERE T2.resolution > 900 GROUP BY T2.artist_name HAVING count(*) >= 1
human
What is ids of the songs whose resolution is higher than the resolution of any songs with rating lower than 8?
assistant
SELECT f_id FROM song WHERE resolution > (SELECT max(resolution) FROM song WHERE rating < 8)
human
What is the name of the artist who produced the shortest song?
assistant
SELECT T1.artist_name FROM song AS T1 JOIN files AS T2 ON T1.f_id = T2.f_id ORDER BY T2.duration LIMIT 1
human
Return the gender and name of artist who produced the song with the lowest resolution.
assistant
SELECT T1.gender , T1.artist_name FROM artist AS T1 JOIN song AS T2 ON T1.artist_name = T2.artist_name ORDER BY T2.resolution LIMIT 1 ;