Write SQL code that could be used from these seven tables below 1. List the tota
ID: 3699009 • Letter: W
Question
Write SQL code that could be used from these seven tables below
1. List the total number of parts ordered on each day. Rank your results in ascending order on
order date.
2. List the full name and mailing address of customers who placed an order on 04-AUG-2013. If
same customer has placed more than one order on this day, only show his/her information
once.
3. List the order date, order number, total quoted price for each order placed between 03-AUG-
2013 and 06-AUG-2013.
4. List the average commission rate (rename to AVG_RATE) and the highest total commission
(rename to MAX_COMMISSION) of sales representatives who sold SG class items.
5. List the warehouse number and the total number of orders from each warehouse.
6. List the full name of the sales representatives, order number, and total quoted price for each
order (rename to TQP) handled by each sales representative.
Table: PART Column Data Type gth Precision Scale Nullable PART NUMBER PART DESCRIPTION UNITS ON HAND ITEM CLASS WAREHOUSE NUMBERNUMBER UNIT PRICE VARCHAR2 VARCHAR2 NUMBER CHAR No - Yes Yes - Yes Yes 2 Yes 12 NUMBE 7Explanation / Answer
1. select order_date, sum(Number_Ordered) as total_parts from part,order_line,orders where part.part_number=order_line.part_number and order_line.order_number=orders.order_number
group by order_date
sort by order_date ASC;
-----------------------------------------------------------------------
2. select cfirst || clast as NAME, street ||',' ||city||','||state||','||zip_code as Mailing_Address from customer, orders where customer.c_number=orders.c_number;
where order_date='04-AUG-2013';
----------------------------------------------------------------------
3.select order_date,orders.order_number,sum(quoted_price) as Total_Quoted_Price from order_line,orders where orders.order_number=order_line.order_number and order_date between '03-AUG-2013' and '06-AUG-2013'
group by orders.order_number.
-----------------------------------------------------------------
4.select avg(commission_rate) as AVG_RATE, max(total_commission) as MAX_COMMISSION
from sales_rep,customer,orders,order_line,part
where sales_rep.SLSREP_Number=customer.SLSREP_Number and customer.c_number=orders.c_number and orders.order_number=order_line.order_number and order_line.part_number=part.part_number
and item_clas='SG';
-----------------------------------------------------------------------
5. select warehouse_number, sum(number_ordered) from part,order_line where order_line.part_number=part.part_number
group by warehouse_number;
------------------------------------------------------------------------
6. select SRFIRST||SRLAST as Full_Name,orders.order_number,sum(quoted_price) as TQP
from sales_rep,customer,orders,order_line
where sales_rep.SLSREP_Number=customer.SLSREP_Number and customer.c_number=orders.c_number and orders.order_number=order_line.order_number
group by sales_rep.SLSREP_Number;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.