Вы находитесь на странице: 1из 2

TIS3351

Advance Database

Oct2014

Lab02: Advance SQL 2


Requirement: Use the database and tables you have created during
Lab01. Import the script and run all the DDL commands.
Instruction: You are required to write queries on DB2 for the following Entity
Relationship Diagram. Write SQL commands for all questions below. Show
your executable solutions to tutor.

Figure 1. Entity Relationship Diagram for Pine Valley Furniture (version 2).

Before you proceed:


a) What are the important four questions to be asked before we create a query?

1.
1.
1.

Write a SELECT command to display the customer name with custID =


102?
2. Write a SELECT command to display the product name with ProdPrice
> 250?

TIS3351

Advance Database

Oct2014

3. Use JOIN to display the customers who place orders on date 05-232014?
4. Who place orders within this date range 05-01-2014 to 05-31-2014?
Note: write three different commands that could run this query.
5. Write a SELECT command to list the products which names begin with
D.
6. Write a SELECT command to list the products which names begin with
d.
7. Write a SELECT command to list all the products in descending orders.
8. Write a SELECT command to know how many customers there are?
BONUS:
9. Alter table PRODUCT to add one new column Total. Use data type
DECIMAL(10,2).
10. Display columns ProdName, ProdPrice, QtyOnHand, Total in table

PRODUCT. You must display the values for Total as a result of Quantity
multiplied with ProdPrice.

Вам также может понравиться