Bird
0
0

Given the table Products with columns id, name, and price, and the view created as:

medium📝 query result Q13 of 15
SQL - Views
Given the table Products with columns id, name, and price, and the view created as:
CREATE VIEW CheapProducts AS SELECT id, name FROM Products WHERE price < 50;
What will the query SELECT * FROM CheapProducts; return if Products contains:
id | name    | price
1  | Pen     | 10
2  | Notebook| 60
3  | Eraser  | 30
ARows with id 1, 2, and 3 showing all columns
BRows with id 1 and 3 showing id and name columns
CRows with id 2 only showing id and name columns
DNo rows returned because price is not selected
Step-by-Step Solution
Solution:
  1. Step 1: Understand the view definition

    The view selects id and name from Products where price is less than 50.
  2. Step 2: Apply the filter to the data

    Products with price less than 50 are id 1 (price 10) and id 3 (price 30). The view returns only id and name columns.
  3. Final Answer:

    Rows with id 1 and 3 showing id and name columns -> Option B
  4. Quick Check:

    View filters price < 50 and selects id, name [OK]
Quick Trick: View returns filtered columns and rows as defined [OK]
Common Mistakes:
MISTAKES
  • Expecting all columns in view output
  • Including rows that don't meet WHERE condition
  • Thinking view stores data separately

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes