Question

I need help in SQL management studio please. Question: Create the same query as query 5,...

I need help in SQL management studio please. Question: Create the same query as query 5, but only include artists if they have 'Pop' Genre.

Previous question:

Create a list of all composers and artists in your database. Include two columns in your record set (the names of the returned columns are in brackets): 'Composer/Artist Name' and 'Type' (which will indicate whether your results are from the composer or artist table). Order by 'Composer/Artist Name'.

This is the answer for query 5:

SELECT ArtistName AS Composer_Artist_Name,'Artist' AS TYPE FROM tblArtist
UNION (SELECT ComposerName AS Composer_Artist_Name,
'Composer' AS TYPE FROM tblComposer)
ORDER BY Composer_Artist_Name;

This is the create script for the database:

CREATE TABLE tblArtist (
   ArtistID INT NOT NULL PRIMARY KEY,
   ArtistName VARCHAR(100),
   Genre VARCHAR(50));

CREATE TABLE tblComposer (
   ComposerID INT NOT NULL PRIMARY KEY,
   ComposerName VARCHAR(100));

CREATE TABLE tblSong (
   SongID INT NOT NULL PRIMARY KEY,
   SongName VARCHAR(255),
   DateReleased DATE,
   ArtistID INT REFERENCES tblArtist(ArtistID),
   ComposerID INT REFERENCES tblComposer(ComposerID),
   Cost NUMERIC(6,2));

CREATE TABLE tblPlaylist (
   PlaylistID INT NOT NULL PRIMARY KEY,
   PlayListName VARCHAR(255),
   DateCreated DATE);

CREATE TABLE tblPlaylistSongs (
   PlaylistSongID INT NOT NULL PRIMARY KEY,
   PlayListID INT REFERENCES tblPlaylist(PlaylistID),
   SongID INT REFERENCES tblSong(SongID));

--Insert records into tables
INSERT INTO tblArtist VALUES (1, 'Elvis Presley', 'Rock and Roll');
INSERT INTO tblArtist VALUES (2, 'Michael Jackson', 'Pop');
INSERT INTO tblArtist VALUES (3, 'Led Zepplin', 'Rock and Roll');
INSERT INTO tblArtist VALUES (4, 'Bruce Springsteen', 'Rock and Roll');
INSERT INTO tblArtist VALUES (5, 'Steppenwolf', 'Rock and Roll');
INSERT INTO tblArtist VALUES (6, 'The Beatles', 'Pop');
INSERT INTO tblArtist VALUES (7, 'Madonna', 'Pop');
INSERT INTO tblArtist VALUES (8, 'Johnny Cash', 'Rock and Roll');
INSERT INTO tblArtist VALUES (9, 'Prince', 'Pop');

INSERT INTO tblComposer VALUES (1, 'Jeremy Leiber');
INSERT INTO tblComposer VALUES (2, 'Mike Stoller');
INSERT INTO tblComposer VALUES (3, 'Mark James');
INSERT INTO tblComposer VALUES (4, 'June Carter Cash');
INSERT INTO tblComposer VALUES (5, 'Johnny Cash');
INSERT INTO tblComposer VALUES (6, 'Rod Temperton');
INSERT INTO tblComposer VALUES (7, 'Michael Jackson');
INSERT INTO tblComposer VALUES (8, 'Siedah Garrett');
INSERT INTO tblComposer VALUES (9, 'Madonna');
INSERT INTO tblComposer VALUES (10, 'Peter Brown');

INSERT INTO tblSong VALUES (2, 'Hound Dog', '1969-01-01', 1, 1, 1.49);
INSERT INTO tblSong VALUES (3, 'Jailhouse Rocker', '1957-01-01', 1, 2, 1.29);
INSERT INTO tblSong VALUES (4, 'Always on My Mind', '1973-01-01', 1, 3, 0.99);
INSERT INTO tblSong VALUES (5, 'Ring of Fire', '1963-01-01', 8, 4, 1.49);
INSERT INTO tblSong VALUES (6, 'Folsom Prison Blues', '1957-01-01', 8, 5, 1.29);
INSERT INTO tblSong VALUES (7, 'Man in Black', '1971-01-01', 8, 5, 0.99);
INSERT INTO tblSong VALUES (8, 'Billie Jean', '1982-01-01', 2, 7, 1.29);
INSERT INTO tblSong VALUES (9, 'Thriller', '1982-01-01', 2, 6, 1.29);
INSERT INTO tblSong VALUES (10, 'Man in the Mirror', '1987-01-01', 2, 8, 0.99);
INSERT INTO tblSong VALUES (11, 'Like a Prayer', '1989-01-01', 7, 9, 1.29);
INSERT INTO tblSong VALUES (12, 'Material Girl', '1984-01-01', 7, 10, 1.29);
INSERT INTO tblSong VALUES (13, 'Express Yourself', '1989-01-01', 7, 9, 0.99);

INSERT INTO tblPlaylist VALUES (1, 'Rock and Roll Classics', '2018-04-05');
INSERT INTO tblPlaylist VALUES (2, 'Pop Classics', '2018-04-01');
INSERT INTO tblPlaylist VALUES (3, 'Mixed', '2018-04-15');

INSERT INTO tblPlaylistSongs VALUES (1, 1, 2);
INSERT INTO tblPlaylistSongs VALUES (2, 1, 4);
INSERT INTO tblPlaylistSongs VALUES (3, 1, 6);
INSERT INTO tblPlaylistSongs VALUES (4, 1, 3);
INSERT INTO tblPlaylistSongs VALUES (5, 2, 8);
INSERT INTO tblPlaylistSongs VALUES (6, 2, 9);
INSERT INTO tblPlaylistSongs VALUES (7, 2, 10);
INSERT INTO tblPlaylistSongs VALUES (8, 2, 12);
INSERT INTO tblPlaylistSongs VALUES (9, 2, 13);
INSERT INTO tblPlaylistSongs VALUES (10, 3, 2);
INSERT INTO tblPlaylistSongs VALUES (11, 3, 12);
INSERT INTO tblPlaylistSongs VALUES (12, 3, 3);
INSERT INTO tblPlaylistSongs VALUES (13, 3, 8);
INSERT INTO tblPlaylistSongs VALUES (14, 3, 11);
INSERT INTO tblPlaylistSongs VALUES (15, 3, 9);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

/* Here is your edited query to include only result of pop genre*/

SELECT ArtistName AS Composer_Artist_Name,'Artist' AS TYPE FROM tblArtist WHERE tblArtist.Genre="Pop" UNION (SELECT ComposerName AS Composer_Artist_Name, 'Composer' AS TYPE FROM tblComposer) ORDER BY Composer_Artist_Name;

Add a comment
Know the answer?
Add Answer to:
I need help in SQL management studio please. Question: Create the same query as query 5,...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • a. Write five select statements to select data from each table individually. b. Write one select...

    a. Write five select statements to select data from each table individually. b. Write one select statement with joins to list the playlist name, playlist track number, song name, artist name, album name, sorted by playlist name and playlist track number. DROP TABLE Artists CASCADE CONSTRAINTS; DROP TABLE Albums CASCADE CONSTRAINTS; DROP TABLE Songs CASCADE CONSTRAINTS; DROP TABLE Playlists CASCADE CONSTRAINTS; DROP TABLE PlaylistSongs CASCADE CONSTRAINTS; CREATE TABLE Artists ( ArtistID int NOT NULL, ArtistName varchar(255), PRIMARY KEY (ArtistID) );...

  • I need help with the following SQL query for a company database (script given below). The...

    I need help with the following SQL query for a company database (script given below). The name of the Department. The number of employees working in that department. The number of different projects controlled by this department. The name of the project controlled by this department that has the maximum number of employees of the company working on it. The number of the above project. The cumulative sum of the number of employees of the company working on the projects...

  • MICROSOFT SQL SERVER - Create the following views 1.List the employee assigned to the most projects...

    MICROSOFT SQL SERVER - Create the following views 1.List the employee assigned to the most projects 2.List the project with the most hours SCRIPT TO BUILD DATABASE create table department ( dept_ID int not null , dept_name char(50) NOT NULL, manager_ID int not null, manager_start_date date not null, constraint Dept_PK primary key (dept_ID), constraint D_Name_AK unique (dept_name) ); insert into department values(1,'abc',1,'2019-01-08'); insert into department values(2,'abc2',2,'2019-01-08'); insert into department values(3,'abc3',2,'2019-01-08'); insert into department values(4,'abc4',2,'2019-01-08'); /*project table done*/ create table project...

  • Database Management 6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL,...

    Database Management 6. [5] Create the following table: CREATE TABLE customer ( cust_name VARCHAR(30) NOT NULL, address VARCHAR(60), UNIQUE (cust name, address)); A. Run the following inserts and explain why both work and how will you prevent it INSERT INTO customer VALUES ('Alex Doe', NULL); INSERT INTO customer VALUES ('Alex Doe', NULL); 7. [5] Modify the following table definition to ensure that all employees have a minimum wage of $10 CREATE TABLE employee ( empId INT PRIMARY KEY, empName VARCHAR(40)...

  • SQL I have a database CREATE TABLE vendor ( vid CHAR(2) NOT NULL, vname VARCHAR(25) NOT...

    SQL I have a database CREATE TABLE vendor ( vid CHAR(2) NOT NULL, vname VARCHAR(25) NOT NULL, PRIMARY KEY (vid) ); CREATE TABLE category ( catid CHAR(2) NOT NULL, catname VARCHAR(25) NOT NULL, PRIMARY KEY (catid) ); CREATE TABLE product ( pid CHAR(3) NOT NULL, pname VARCHAR(25) NOT NULL, price NUMERIC (7,2) NOT NULL, vid CHAR(2) NOT NULL, categoryid CHAR(2) NOT NULL, PRIMARY KEY (pid)); CREATE TABLE region ( rid CHAR NOT NULL, rname VARCHAR(25) NOT NULL, PRIMARY KEY (rid)...

  • Use the SQL statements provided to create your tables. Write one SQL statement for each of...

    Use the SQL statements provided to create your tables. Write one SQL statement for each of the following problems. You can only use the conditions listed in the tasks. E.g., in task 1, you cannot manually look up pid of Information Systems undergraduate program. Here is the given code: drop table textbook_schedule cascade constraints; drop table textbook_author cascade constraints; drop table schedule cascade constraints; drop table course cascade constraints; drop table textbook cascade constraints; drop table author cascade constraints; drop...

  • Question: Write one SQL statement for the following question: Return number of players whose rating is...

    Question: Write one SQL statement for the following question: Return number of players whose rating is over 1000. Background information: This is a chess tournament management database that stores information about chess players, tournaments, sections, registrations, and pairings. Each player has an ID, name, grade (0 to 12) and rating. Each tournament has a number of sections. Each player can register for a section of a tournament In each round of a tournament, players in the same section will be...

  • Learning Objectives: Learn to define constraints on tables Lean to define primary keys and foreign keys...

    Learning Objectives: Learn to define constraints on tables Lean to define primary keys and foreign keys Exercise                                                                                In Lab 09, we will continue the practice of creating tables. You will need to write SQL statements for the tasks specified below. After you complete them, submit your SQL script (in one *.sql file) to Blackboard by 11:59pm Nov. 16 (Friday). Include your name as a comment in the SQL script submitted. The creation statement for each table is worth one point,...

  • I keep getting this error "You have an error in your SQL syntax; check the manual...

    I keep getting this error "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 4" line 4 is the "Genre char(20) not null," any help or guidance would be lovely create table Games      (gameid int not null auto_increment primary key,       title varchar(100) not null,       Genre char(20) not null,       year_released int not null);      insert into Games(title, Genre,...

  • SQL Query Question: I have a database with the tables below, data has also been aded...

    SQL Query Question: I have a database with the tables below, data has also been aded into these tables, I have 2 tasks: 1. Add a column to a relational table POSITIONS to store information about the total number of skills needed by each advertised position. A name of the column is up to you. Assume that no more than 9 skills are needed for each position. Next, use a single UPDATE statement to set the values in the new...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT