So all I blog about lately is questions from class excercises, but I promise I'll get back to more interesting items after the exam.
In Chapter 4 on excercise 3, is there a need to really use the part table in the query? Part number is listed in the order line table, and I'm not sure what benefit bringing part number in from the part table instead adds to the query.
The question was:
"For each order, list the order number, order date, part number, number of units ordered, and quoted price for each order line that makes up the order."
The code for the solution was:
select o.order_number, o.order_date, p.part_num, ol.num_ordered, ol.quoted_price
from orders o, part p, order_line ol
where o.order_number = ol.order_num
and ol.part_num = p.part_num;
I propose:
select o.order_num, o.order_date, ol.part_num, ol.num_ordered, ol.quoted_price
from orders o, order_line ol
where o.order_num = ol.order_num;
Note that in my tables I have order_num instead of order_number.
Comments