Beginning SQL

Beginning SQL Beginning SQL

marjan.fesb.hr
from marjan.fesb.hr More from this publisher
20.07.2013 Views

Chapter 5 164 chairperson now also requires that you store the price of the DVD. This requires a new column in the Films table, to be called DVDPrice. Executing the following SQL creates this column: ALTER TABLE Films ADD DVDPrice DECIMAL(12,2); In MS Access, use the following ALTER TABLE statement: ALTER TABLE Films ADD DVDPrice NUMBER DECIMAL; After executing the ALTER TABLE statement, add the prices of DVDs with the following UPDATE statements: UPDATE Films SET DVDPrice = 12.99 WHERE FilmId = 2; UPDATE Films SET DVDPrice = 9.99 WHERE FilmId = 4; UPDATE Films SET DVDPrice = 15.99 WHERE FilmId = 6; UPDATE Films SET DVDPrice = 12.99 WHERE FilmId = 7; UPDATE Films SET DVDPrice = 2.99 WHERE FilmId = 8; UPDATE Films SET DVDPrice = 8.95 WHERE FilmId = 9; UPDATE Films SET DVDPrice = 12.99 WHERE FilmId = 11; UPDATE Films SET DVDPrice = 9.99 WHERE FilmId = 12; UPDATE Films SET DVDPrice = 12.99 WHERE FilmId = 15; UPDATE Films SET DVDPrice = 8.95 WHERE FilmId = 13; With all the proper information in place, you can follow along with all the examples in this section. The first function covered here is the CEILING() function.

Chapter 5<br />

164<br />

chairperson now also requires that you store the price of the DVD. This requires a new column in the<br />

Films table, to be called DVDPrice. Executing the following <strong>SQL</strong> creates this column:<br />

ALTER TABLE Films<br />

ADD DVDPrice DECIMAL(12,2);<br />

In MS Access, use the following ALTER TABLE statement:<br />

ALTER TABLE Films<br />

ADD DVDPrice NUMBER DECIMAL;<br />

After executing the ALTER TABLE statement, add the prices of DVDs with the following UPDATE statements:<br />

UPDATE Films<br />

SET DVDPrice = 12.99<br />

WHERE FilmId = 2;<br />

UPDATE Films<br />

SET DVDPrice = 9.99<br />

WHERE FilmId = 4;<br />

UPDATE Films<br />

SET DVDPrice = 15.99<br />

WHERE FilmId = 6;<br />

UPDATE Films<br />

SET DVDPrice = 12.99<br />

WHERE FilmId = 7;<br />

UPDATE Films<br />

SET DVDPrice = 2.99<br />

WHERE FilmId = 8;<br />

UPDATE Films<br />

SET DVDPrice = 8.95<br />

WHERE FilmId = 9;<br />

UPDATE Films<br />

SET DVDPrice = 12.99<br />

WHERE FilmId = 11;<br />

UPDATE Films<br />

SET DVDPrice = 9.99<br />

WHERE FilmId = 12;<br />

UPDATE Films<br />

SET DVDPrice = 12.99<br />

WHERE FilmId = 15;<br />

UPDATE Films<br />

SET DVDPrice = 8.95<br />

WHERE FilmId = 13;<br />

With all the proper information in place, you can follow along with all the examples in this section. The<br />

first function covered here is the CEILING() function.

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

Saved successfully!

Ooh no, something went wrong!