Which query would produce the desired output?

View the Exhibit and examine the structure of the ORDER_ITEMS table.
You need to display the ORDER_ID of the order that has the highest total value among
all the orders in the ORDER_ITEMS table.
Which query would produce the desired output?

View the Exhibit and examine the structure of the ORDER_ITEMS table.
You need to display the ORDER_ID of the order that has the highest total value among
all the orders in the ORDER_ITEMS table.
Which query would produce the desired output?

A.
SELECT order_id
FROM order_items
WHERE(unit_price*quantity) = MAX(unit_price*quantity)
GROUP BY order_id;

B.
SELECT order_id
FROM order_items
WHERE(unit_price*quantity) = (SELECT MAX(unit_price*quantity) FROM
order_items)
GROUP BY order_id;

C.
SELECT order_id
FROM order_items
WHERE (unit_price*quantity) = (SELECT MAX(unit_price*quantity) FROM
order_items
GROUP BY order_id);

D.
SELECT order_id
FROM order_items
GROUP BY order_id
HAVING SUM(unit_price*quantity) =(SELECT MAX(SUM(unit_price*quantity))
FROM order_items GROUP BY order_id);



Leave a Reply 2

Your email address will not be published. Required fields are marked *


Bes

Bes

C.

Gives all IDs with the highest values of unit_price*quantity.

robkam

robkam

C is wrong, D is correct