20.07.2013 Views

Beginning SQL

Beginning SQL

Beginning SQL

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 9<br />

Exercises<br />

286<br />

Assume that a new table called FilmStars has been added to the Film Club database and that it has been<br />

populated with the following values:<br />

CREATE TABLE FilmStars<br />

(<br />

StarId integer,<br />

StarName varchar(100),<br />

StarAge integer<br />

);<br />

INSERT INTO FilmStars(StarId, StarName, StarAge)<br />

VALUES (1,’Boris Carlot’,102);<br />

INSERT INTO FilmStars(StarId, StarName, StarAge)<br />

VALUES (1,’Scarlet O’’Hairpin’,89);<br />

INSERT INTO FilmStars(StarId, StarName, StarAge)<br />

VALUES (3,’Boris Carlot’,102);<br />

INSERT INTO FilmStars(StarId, StarName, StarAge)<br />

VALUES (4,’Michael Hourglass’,56);<br />

INSERT INTO FilmStars(StarId, StarName, StarAge)<br />

VALUES (5,’Dusty Hoffperson’,48);<br />

INSERT INTO FilmStars(StarId, StarName, StarAge)<br />

VALUES (6,’Boris Carlot’,102);<br />

INSERT INTO FilmStars(StarId, StarName, StarAge)<br />

VALUES (7,’Dusty Hoffperson’,48);<br />

You can either type the code in yourself or download this file from the book’s Web site, found at<br />

www.wrox.com.<br />

1. As you can see, there are quite a few duplicate entries. Write the <strong>SQL</strong> to remove the unneeded<br />

duplicate rows, leaving just the one row.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!