CPSC340A
Database Systems

Activity 2

Expressions

Sales Orders Database

  1. What if we adjusted each product price by reducing it 5 percent?

    +---------------+----------------+-----------+
    | ProductNumber | WholesalePrice | NewPrice  |
    +---------------+----------------+-----------+
    |             1 |         804.00 |  763.8000 |
    |             1 |         854.22 |  811.5090 |
    |             2 |        1269.00 | 1205.5500 |
    |             2 |        1477.81 | 1403.9195 |
    |             3 |          54.19 |   51.4805 |
    |             3 |          57.27 |   54.4065 |
    |             4 |          44.22 |   42.0090 |
    |             4 |          41.62 |   39.5390 |
    |             5 |           5.38 |    5.1110 |
    |             5 |           5.87 |    5.5765 |
    |             6 |         403.22 |  383.0590 |
    |             6 |         448.73 |  426.2935 |
    |             7 |          31.12 |   29.5640 |
    |             8 |          39.32 |   37.3540 |
    |             8 |          37.88 |   35.9860 |
    |             9 |          21.53 |   20.4535 |
    |            10 |          22.86 |   21.7170 |
    |            11 |        1076.62 | 1022.7890 |
    |            11 |        1178.65 | 1119.7175 |
    |            12 |          14.51 |   13.7845 |
    .
    .
    .
    (90 rows)
  2. Show me a list of orders made by each customer in descending date order. (Hint: You might need to order by more than one column for the information to display properly.)

    +------------+------------+-------------+
    | CustomerID | OrderDate  | OrderNumber |
    +------------+------------+-------------+
    |       1001 | 2013-02-27 |         931 |
    |       1001 | 2013-02-21 |         898 |
    |       1001 | 2013-02-20 |         887 |
    |       1001 | 2013-02-14 |         855 |
    |       1001 | 2013-02-13 |         851 |
    |       1001 | 2013-02-12 |         840 |
    |       1001 | 2013-02-08 |         817 |
    |       1001 | 2013-01-23 |         732 |
    |       1001 | 2013-01-21 |         723 |
    |       1001 | 2013-01-17 |         701 |
    |       1001 | 2013-01-10 |         657 |
    |       1001 | 2013-01-09 |         649 |
    |       1001 | 2013-01-07 |         632 |
    |       1001 | 2013-01-02 |         608 |
    |       1001 | 2012-12-31 |         596 |
    |       1001 | 2012-12-29 |         587 |
    |       1001 | 2012-12-25 |         567 |
    |       1001 | 2012-12-24 |         564 |
    |       1001 | 2012-12-11 |         501 |
    |       1001 | 2012-12-06 |         475 |
    |       1001 | 2012-11-30 |         452 |
    |       1001 | 2012-11-29 |         443 |
    |       1001 | 2012-11-29 |         448 |
    .
    .
    .
    (944 rows)
  3. Compile a complete list of vendor names and addresses in vendor name order.

    +------------------------+---------------------------------------------+-----------------+
    | VendName               | VendCompleteAddress                         | VendPhoneNumber |
    +------------------------+---------------------------------------------+-----------------+
    | Armadillo Brand        | 12330 Side Road Lane, Dallas  TX  75137     | (214) 444-9876  |
    | Big Sky Mountain Bikes | Glacier Bay South, Anchorage  AK  99209     | (907) 222-1234  |
    | Dog Ear                | 575 Madison Ave., New York  NY  10003       | (212) 888-9876  |
    | Kona, Incorporated     | PO Box 10429, Redmond  WA  98052            | (425) 333-1234  |
    | Lone Star Bike Supply  | 7402 Kingman Drive, El Paso  TX  79915      | (915) 666-9876  |
    | Nikoma of America      | 88 Old North Road Ave, Ballard  WA  91324   | (206) 666-1234  |
    | ProFormance            | 29 N. Quail St., Albany  NY  12012          | (518) 444-1234  |
    | Shinoman, Incorporated | 3042 19th Avenue South, Bellevue  WA  98001 | (425) 888-1234  |
    | Sun Sports Suppliers   | PO Box 8082, Santa Monica  CA  91003        | (310) 777-9876  |
    | Viscount               | 1911 Commerce Way, St. Louis  MO  63127     | (314) 777-1234  |
    +------------------------+---------------------------------------------+-----------------+
    (10 rows)

Bowling League Database

  1. Show next year’s tournament date for each tournament location.

    +--------------------+-------------+---------------------+
    | TourneyLocation    | TourneyDate | NextYearTourneyDate |
    +--------------------+-------------+---------------------+
    | Acapulco Lanes     | 2012-12-04  | 2013-12-03          |
    | Acapulco Lanes     | 2012-10-16  | 2013-10-15          |
    | Bolero Lanes       | 2012-11-06  | 2013-11-05          |
    | Bolero Lanes       | 2012-09-18  | 2013-09-17          |
    | Bolero Lanes       | 2013-07-26  | 2014-07-25          |
    | Imperial Lanes     | 2012-11-13  | 2013-11-12          |
    | Imperial Lanes     | 2012-09-25  | 2013-09-24          |
    | Imperial Lanes     | 2013-08-09  | 2014-08-08          |
    | Red Rooster Lanes  | 2012-09-04  | 2013-09-03          |
    | Red Rooster Lanes  | 2013-07-12  | 2014-07-11          |
    | Red Rooster Lanes  | 2012-10-23  | 2013-10-22          |
    | Sports World Lanes | 2012-11-20  | 2013-11-19          |
    | Sports World Lanes | 2013-08-02  | 2014-08-01          |
    | Sports World Lanes | 2012-10-02  | 2013-10-01          |
    | Thunderbird Lanes  | 2012-10-30  | 2013-10-29          |
    | Thunderbird Lanes  | 2012-09-11  | 2013-09-10          |
    | Thunderbird Lanes  | 2013-07-19  | 2014-07-18          |
    | Totem Lanes        | 2012-10-09  | 2013-10-08          |
    | Totem Lanes        | 2012-11-27  | 2013-11-26          |
    | Totem Lanes        | 2013-08-16  | 2014-08-15          |
    +--------------------+-------------+---------------------+
    (20 rows)
  2. List the name and phone number for each member of the league.

    +---------------------+----------------+
    | Bowler              | Phone          |
    +---------------------+----------------+
    | Black, Alastair     | (206) 555-1189 |
    | Cunningham, David   | (206) 555-8122 |
    | Ehrlich, Zachary    | (206) 555-9857 |
    | Fournier, Barbara   | (206) 555-9876 |
    | Fournier, David     | (206) 555-9876 |
    | Hallmark, Alaina    | (206) 555-8990 |
    | Hallmark, Bailey    | (206) 555-8990 |
    | Hallmark, Elizabeth | (206) 555-8990 |
    | Hallmark, Gary      | (206) 555-8990 |
    | Hernandez, Kendra   | (206) 889-9191 |
    | Hernandez, Michael  | (206) 889-9191 |
    | Kennedy, Angel      | (206) 555-7854 |
    | Kennedy, John       | (206) 555-7854 |
    | Patterson, Ann      | (206) 555-3487 |
    | Patterson, Kathryn  | (206) 555-3487 |
    | Patterson, Megan    | (206) 555-3487 |
    | Patterson, Neil     | (206) 555-3487 |
    | Patterson, Rachel   | (206) 555-3487 |
    | Pundt, Steve        | (206) 555-3412 |
    | Rosales, Joe        | (206) 555-9482 |
    | Sheskey, Richard    | (206) 555-9893 |
    | Sheskey, Sara       | (206) 555-9893 |
    | Thompson, Mary      | (206) 555-8989 |
    | Thompson, Sarah     | (206) 555-8989 |
    | Thompson, William   | (206) 555-8989 |
    | Viescas, Caleb      | (206) 882-8878 |
    | Viescas, Carol      | (206) 555-7295 |
    | Viescas, David      | (206) 882-8878 |
    | Viescas, John       | (206) 881-5596 |
    | Viescas, Michael    | (206) 881-5596 |
    | Viescas, Stephanie  | (206) 882-8878 |
    | Viescas, Suzanne    | (206) 881-5596 |
    +---------------------+----------------+
    (32 rows)
  3. Give me a listing of each team’s lineup. (Hint: Base this query on the Bowlers table.)

    +--------+---------------------+
    | TeamID | Bowler              |
    +--------+---------------------+
    |      1 | Fournier, Barbara   |
    |      1 | Fournier, David     |
    |      1 | Kennedy, John       |
    |      1 | Sheskey, Sara       |
    |      2 | Patterson, Ann      |
    |      2 | Patterson, Neil     |
    |      2 | Viescas, David      |
    |      2 | Viescas, Stephanie  |
    |      3 | Black, Alastair     |
    |      3 | Cunningham, David   |
    |      3 | Kennedy, Angel      |
    |      3 | Viescas, Carol      |
    |      4 | Hallmark, Elizabeth |
    |      4 | Hallmark, Gary      |
    |      4 | Patterson, Kathryn  |
    |      4 | Sheskey, Richard    |
    |      5 | Hernandez, Kendra   |
    |      5 | Hernandez, Michael  |
    |      5 | Viescas, John       |
    |      5 | Viescas, Suzanne    |
    |      6 | Ehrlich, Zachary    |
    |      6 | Hallmark, Alaina    |
    |      6 | Thompson, Sarah     |
    |      6 | Viescas, Caleb      |
    |      7 | Patterson, Megan    |
    |      7 | Thompson, Mary      |
    |      7 | Thompson, William   |
    |      7 | Viescas, Michael    |
    |      8 | Hallmark, Bailey    |
    |      8 | Patterson, Rachel   |
    |      8 | Pundt, Steve        |
    |      8 | Rosales, Joe        |
    +--------+---------------------+
    (32 rows)