solution

Write a SQL query that returns the genres that have at least one track of that genre (order alphabetically).

CREATE TABLE [Track]
(
 [TrackId] INTEGER NOT NULL,
 [Name] NVARCHAR(200) NOT NULL,
 [AlbumId] INTEGER,
 [MediaTypeId] INTEGER NOT NULL,
 [GenreId] INTEGER,
 [Composer] NVARCHAR(220),
 [Milliseconds] INTEGER NOT NULL,
 [Bytes] INTEGER,
 [UnitPrice] NUMERIC(10,2) NOT NULL,
 CONSTRAINT [PK_Track] PRIMARY KEY ([TrackId]),
 FOREIGN KEY ([AlbumId]) REFERENCES [Album] ([AlbumId]) 
 ON DELETE NO ACTION ON UPDATE NO ACTION,
 FOREIGN KEY ([GenreId]) REFERENCES [Genre] ([GenreId]) 
 ON DELETE NO ACTION ON UPDATE NO ACTION,
 FOREIGN KEY ([MediaTypeId]) REFERENCES [MediaType] ([MediaTypeId]) 
 ON DELETE NO ACTION ON UPDATE NO ACTION
);

CREATE TABLE [Genre]
(
 [GenreId] INTEGER NOT NULL,
 [Name] NVARCHAR(120),
 CONSTRAINT [PK_Genre] PRIMARY KEY ([GenreId])
);

 
"Looking for a Similar Assignment? Get Expert Help at an Amazing Discount!"
Looking for a Similar Assignment? Our Experts can help. Use the coupon code SAVE30 to get your first order at 30% off!

Hi there! Click one of our representatives below and we will get back to you as soon as possible.

Chat with us on WhatsApp