Ok, I have got a twister. Please help. I need to create a view that consists of the order_num, and order total for each order currently on file. Sorting the rows by order_num. Using TOTAL_AMOUNT as the name for the order total. Tables: Orders: order_num, order_date, customer_num order_line: Order_num, Part_num, Num_ordered, quoted_price Part: part_num, description, on_hand, class, warehouse, price I missed this question on a test and I know I will see it again on my final. Can someone point me in the right direction?
This is off the cuff and untested, but the view should look vaguely like: create view vw_order_total as select o.Order_num, sum(ol.quoted_price) as Total_amount from orders o join order_lin ol on o.order_num = ol.order_num group by o.Order_num And then as Matt very astutely pointed out, you cannot have an order by inside a view, and generally wouldn't want to anyway. So, you get the order by from querying the view: select Order_num, Total_amount from vw_order_total order by o.order_num That is assuming that the quoted_price in order_line is the entire price for that line. The third table is simply unneeded as long as quoted_price is indeed the entire price for that line item. [Edited to fix the order by inside a view. Thanks again, Matt.]