Name: Morales, Arjay Christopher D. Assignment #: 6-2
Name: Morales, Arjay Christopher D. Assignment #: 6-2
Assignment #: 6-2
:
Introduction to SQL Activity
Course Code: NCP 1202 Activity Title:
1. Add the following row to the SALES_REP table: rep number: 25, last name: Lim; first name: Louis;
street: 535 Vincent; city: Grove; state: FL; zip code: 33321; commission: 0.00; and rate: 0.05. Display
the contents of the SALES_REP table.
3. List the part number, description, and price for all parts.
SELECT CUSTOMER_NAME
FROM CUSTOMER
WHERE CREDIT_LIMIT >= 10000;
5. List the order number for each order placed by customer number 608 on 10/23/2010. (Hint: Use the
YYYY-MM-DD' format for date values)
SELECT ORDER_NUM
FROM ORDERS
WHERE CUSTOMER_NUM = '608' AND ORDER_DATE = '2010-10-23';
6. List the number and name of each customer represented by sales rep 35 or sales rep 65.
8. List the part number, description, and number of units on hand for each part that has between 10 and 25
units on hand, including both 10 and 25. (USE THE BETWEEN CLAUSE)
9. List the part number, part description, and on-hand value (units on hand * unit price) of each part in item
class SG. Assign the name ON_HAND_VALUE to the computed column.
10. List the part number, part description, and on-hand value for each part who’s on-hand value is at least
$7,500. Assign the name ON_HAND_VALUE to the computed column.
11. Use the IN operator to list the part number and part description of each part in item class AP or SG.
12. Find the number and name of each customer whose name begins with the letter “B.”
SELECT *
FROM PART
ORDER BY WAREHOUSE, PART_NUM;
14. How many customers have balances that are more than their credit limits?
15. Find the total of the balances for all customers represented by sales rep 65 with balances that are less
than their credit limits.
16. List the part number, part description, and on-hand value of each part whose number of units on hand is
more than the average number of units on hand for all parts. (Hint: Use a subquery.)
17. What is the price of the least expensive part in the database?
SELECT MIN(PRICE)
FROM PART;
18. What is the part number, description, and price of the least expensive part in the database? (Hint: Use a
subquery.)
19. List the sum of the balances of all customers for each sales rep, but restrict the output to those sales reps
for which the sum is more than $10,000.
20. Create a table named SALES_REP. The table has the same structure as the REP table except the
LAST_NAME column should use the VARCHAR data type and the COMMISSION and RATE
columns should use the INT data type. Execute the command to describe the layout and characteristics
of the SALES_REP table.