1. List the total number of parts ordered on each day. Rank your results in asce
ID: 3741531 • Letter: 1
Question
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. 7. List the part number and part description of parts with units on hand higher than the average units on hand across all parts.
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. 7. List the part number and part description of parts with units on hand higher than the average units on hand across all parts.
SELECT FRON ORDER LNE ORDER NUMBER PART NUMBER NUMBER ORDERED 21 05 22.95 4999
Explanation / Answer
Please find my SQL Query:
1.select fullname,part_description,sum(number_ordered) as total_parts from
(
select c.clast||' '||c.cfirst as fullname,p.part_description,ordl.number_ordered from customer c
join orders ord on c.c_number=ord.c_number
join order_line ordl on ord.order_number=ordl.order_number
join part p on ordl.part_number=p.part_number
)
group by fullname,part_description;select sum(num),dt from (select a.number_ordered as num ,b.order_date as dt from order_line a
join orders b on a.order_number=b.order_number order by dt) group by dt;
2.select a.clast||' '||a.cfirst as fullname,a.street||' '||a.city||' '||a.state||' '||a.zip_code as address from customer a
join orders b on a.c_number=b.c_number
where b.order_date=TO_DATE('04-08-2013','dd-mm-yyyy');
3.select order_number,order_date,sum(quoted_price) from
(
select a.order_number,a.order_date,b.quoted_price from orders a
join order_line b on a.order_number=b.order_number
where a.order_date between TO_DATE('04-08-2013','dd-mm-yyyy') and TO_DATE('06-08-2013','dd-mm-yyyy')
) group by order_number,order_date;
4.select sr.commission_rate as AVG_RATE,sr.total_commission as MAX_COMMISSION from sales_rep sr
join customer c on sr.slsrep_number=c.slsrep_number
join orders ord on c.c_number=ord.c_number
join order_line ordl on ord.order_number=ordl.order_number
join part p on ordl.part_number=p.part_number and p.item_class='SG';
5.select a.warehouse_number,sum(b.number_ordered) as total_number from part a
join order_line b on a.part_number=b.part_number
group by a.warehouse_number;
6.select full_name,ord_num,sum(TQP) as TQP from
(
select sr.srlast||' '||sr.srfirst as full_name,ordl.order_number as ord_num,ordl.quoted_price as TQP
from sales_rep sr
join customer c on sr.slsrep_number=c.slsrep_number
join orders ord on c.c_number=ord.c_number
join order_line ordl on ord.order_number=ordl.order_number
)
group by full_name,ord_num;
7.select part_number,part_description from part
where units_on_hand>(select avg(units_on_hand) from part);
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.