Please sorry my friends, I'm coming back | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 5

Please sorry my friends, I'm coming back

You are managing a delivery office and need to prioritize your orders. Order is considered a high priority order if - the purchase total exceeds $400 and - the customer's age is greater than 40 or the distance from the office to the delivery point is under 10 miles. You are given the following 'orders' table with details:

11th Sep 2021, 9:48 AM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar
5 Answers
+ 1
SELECT * FROM Orders WHERE (Age > 40 OR Distance < 10) AND Price > 400 ORDER BY Price;
14th Sep 2021, 4:04 AM
Bernard Towindo
Bernard Towindo - avatar
0
And what are your thoughts on how the query should look?
11th Sep 2021, 10:27 AM
Brian
Brian - avatar
0
SELECT * FROM Orders WHERE Price > 400 AND Age > 40 OR Distance < 10 ORDER BY Price;
11th Sep 2021, 10:38 AM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar
0
Notice that the problem description implies there should be parentheses around the OR expression. (Age > 40 OR Distance < 10) Even if Age<=40 it will still be high priority if Distance<10 miles.
11th Sep 2021, 1:16 PM
Brian
Brian - avatar
0
Let me see
12th Sep 2021, 7:37 AM
Jamilu Abubakar Sadiq
Jamilu Abubakar Sadiq - avatar