How do you get sales between 100 and 500 inclusive?

Study for the SQL Basics Test. Improve your knowledge with multiple choice questions and detailed explanations. Prepare effectively to master SQL concepts!

Multiple Choice

How do you get sales between 100 and 500 inclusive?

Explanation:
To capture a range that includes both endpoints, you want a condition that treats the boundaries as part of the results. SQL’s BETWEEN ... AND does exactly that: it returns values from the lower bound up to the upper bound, including both. So amount BETWEEN 100 AND 500 will include 100, 500, and every value in between, giving you all sales with amounts in that inclusive range. Other forms miss endpoints or use a different upper limit: amount > 100 AND amount < 500 excludes 100 and 500; amount BETWEEN 200 AND 300 only covers 200–300; amount >= 100 AND amount <= 400 covers 100 through 400, missing amounts above 400 like 401–500.

To capture a range that includes both endpoints, you want a condition that treats the boundaries as part of the results. SQL’s BETWEEN ... AND does exactly that: it returns values from the lower bound up to the upper bound, including both. So amount BETWEEN 100 AND 500 will include 100, 500, and every value in between, giving you all sales with amounts in that inclusive range.

Other forms miss endpoints or use a different upper limit: amount > 100 AND amount < 500 excludes 100 and 500; amount BETWEEN 200 AND 300 only covers 200–300; amount >= 100 AND amount <= 400 covers 100 through 400, missing amounts above 400 like 401–500.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy