Bird
0
0

Given the table Orders with columns OrderID, CustomerID, and Amount, and the view HighValueOrders defined as:

medium📝 query result Q4 of 15
SQL - Views
Given the table Orders with columns OrderID, CustomerID, and Amount, and the view HighValueOrders defined as:
CREATE VIEW HighValueOrders AS SELECT OrderID, Amount FROM Orders WHERE Amount > 1000;

What will the query SELECT * FROM HighValueOrders; return?
AAn error because CustomerID is missing in the view.
BAll orders showing OrderID, CustomerID, and Amount.
COnly orders with Amount less than or equal to 1000.
DAll orders with Amount greater than 1000 showing only OrderID and Amount.
Step-by-Step Solution
Solution:
  1. Step 1: Understand the view definition

    The view selects OrderID and Amount from Orders where Amount is greater than 1000.
  2. Step 2: Analyze the SELECT query on the view

    Query selects all columns from the view, which are OrderID and Amount for orders with Amount > 1000.
  3. Final Answer:

    All orders with Amount greater than 1000 showing only OrderID and Amount. -> Option D
  4. Quick Check:

    View filters and columns = Orders with Amount > 1000, OrderID & Amount [OK]
Quick Trick: View returns only columns and rows defined in its SELECT [OK]
Common Mistakes:
MISTAKES
  • Expecting all columns from base table
  • Thinking view includes rows not matching WHERE
  • Assuming missing columns cause errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes