Beginning SQL
Beginning SQL Beginning SQL
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.
- Page 316: Chapter 4 If you’re using IBM DB2
- Page 320: Chapter 4 140 index helps speed up
- Page 324: Chapter 4 142 The results you get m
- Page 328: Chapter 4 144 The results of the qu
- Page 332: Chapter 4 146 Remember, IBM DB2 doe
- Page 336: Chapter 4 148 UPDATE Films SET Film
- Page 340: Chapter 4 150 Finally, you do the s
- Page 344: Chapter 4 152 SELECT * FROM MemberD
- Page 348: Chapter 4 ❑ Choose meaningful nam
- Page 354: 5 Manipulating Data In Chapter 3, y
- Page 358: The results of this query are as fo
- Page 362: You can raise a number to any power
- Page 366: To demonstrate the sort of results
- Page 372: Chapter 5 The FLOOR() Function The
- Page 376: Chapter 5 DVDPrice ROUND(DVDPrice,1
- Page 380: Chapter 5 Note that, as with all th
- Page 384: Chapter 5 The TRIM() Functions Trim
- Page 388: Chapter 5 174 In Oracle and IBM’s
- Page 392: Chapter 5 176 FirstName SOUNDEX(Fir
- Page 396: Chapter 5 Date Functions 178 Someti
- Page 400: Chapter 5 The syntax for the CAST()
- Page 404: Chapter 5 NULLs and Strings 182 NUL
- Page 408: Chapter 5 184 SELECT FirstName, Las
- Page 412: Chapter 5 186 This SQL copies over
- Page 416: Chapter 5 You also learned that mat
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.