I would like to rewrite this SQL. However, I need it to exclude the sql in() operator and the limit clause.
The query will output the emailAddress, orderID and quantity. It is searching for customers who have bought three or more of the most expensive flower available, in a single order.
I'm not too sure how to do this, any help would be greatly appreciated.
SELECT customer.emailAddress, custOrder.orderId, flowerPurchase.quantity
FROM flowerPurchase
INNER JOIN custOrder ON flowerPurchase.orderId = custOrder.orderId
INNER JOIN customer on customer.customerId = custOrder.customerId
WHERE flowerID IN(
SELECT flowerID
FROM flower
ORDER BY unitPrice DESC
LIMIT 1
)
AND quantity >= 3