PRO
Md
asked

Expert
Udayan Shakya answered
Hi there!
The problem statement is instructing you to select those rows from the Products table whose price is between 145 and 220, BUT the query should not select those rows whose price is either exactly 145 or 220.
This is basically a trick question because if you use the following query, then your solution will be wrong:
SELECT *
FROM Products
WHERE price BETWEEN 145 AND 220;It's because BETWEEN will also select those rows whose price is 145 or 220.
So if you want to solve this problem using the BETWEEN operator, you need to use BETWEEN 146 AND 219.
This way, you've successfully excluded 145 and 220.
Correct Solution
SELECT *
FROM Products
WHERE price BETWEEN 146 AND 219;Hope this helps! Let me know if you have more questions.
SQL
This question was asked as part of the Learn SQL Basics course.
Our Experts
Sudip BhandariHead of Growth/Marketing
Apekchhya ShresthaSenior Product Manager
Kelish RaiTechnical Content Writer
Abhilekh GautamSystem Engineer
Palistha SinghTechnical Content Writer
Sarthak BaralSenior Content Editor
Saujanya Poudel
Abhay Jajodia
Nisha SharmaTechnical Content Writer
Udayan ShakyaTechnical Content Writer