order by non-table attribute help
Hi, I wonder if someone could help me out.
I have created the following query:
SELECT order_id,sum(suggested_whlsl_price*quantity)
FROM order_item, product
WHERE product.p_id = order_item.product_id
GROUP BY order_id
This displays my order ID numbers along with the total value of the order. However I can only get it to order by order_id.
What I want to actually do is order it by the value of the order and only return, say the first 5 rows, so in effect im selecting the 5 most expensive orders from the database.
Now I'm still fairly new to Oracle, however I have been studying hard and I'm either missing something fairly obvious or I'm getting brain freeze because I've been trying for hours to get it to work now.
If someone could help me out with this I would HUGELY appreciate it :)
Thank you in advance
Rich