Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

, Track Trackid Name Album -MediaType e- 3 AlbumId Artistid Name MediaTypeld Nam

ID: 3754914 • Letter: #

Question

, Track Trackid Name Album -MediaType e- 3 AlbumId Artistid Name MediaTypeld Name Tite Artistld MediaTypeld Genreld Composer Milliseconds Genre Genreld Name PlaylistTrack Playlistld Trackld Playlist Playlistid Name oBytes UnitPrice InvoiceLine InvoiceLineld Invoiceld Trackld UnitPrice Quantity Employee Employeeld LastName FirstName Tite ReportsTo BirthDate HireDate Address Customer Customerld FirstName LastName Invoice Invoiceld CustomerId InvoiceDate BillingAddress BillingCity BillingState BillingCountry illingPostalCode Total Company Address State Country PostalCode Phone State Country PostalCode Phone Fax SupportRepld

Explanation / Answer

In the above question we need to use column alias and row alias. Column alias syntax follows as :

SELECT column_name AS alias_name
FROM table_name;

Row alias syntax in as follows:

Hence, we need to alias in case of the length of the track since it is not available directly and needs to be calculated as Track.miliseconds / 1000. Moreover, we need to select that genreId which has name metal. Hence, we first need to find that using nested querying. Hence, the complete query (query23.sql) would be :

select T.Name as Name, (T.miliseconds / 1000) as LengthSeconds

from Track as T

where T.GenreId = (select G.GenreId from Genre as G where G.Name = "metal");