Which Sql Statements correctly retrieves records from a 'Commodity' table where the Price is either above 1000 or the product Category is 'Sales'?
Which Sql Statements correctly retrieves records from a 'Commodity' table where the Price is either above 1000 or the product Category is 'Sales'?
Solution
The word "either ... or" means a record qualifies if at least one condition is true, so the two conditions must be joined with OR. Rows are filtered using the WHERE clause, and the text value 'Sales' must be in quotes. Option 1 does all three correctly.
Option 2: AND returns only rows where both conditions are true (Price above 1000 and Category 'Sales'), which is stricter than "either or".
Option 3: IF is not used to filter rows in a SELECT statement. The WHERE clause is required.
Option 4: In standard SQL, || is the string concatenation operator, not a logical OR. Also, Sales without quotes would be read as a column name, not a text value.
Related questions:
2025: 22 May Shift 1