Bird
0
0

You want to create a view that shows only the top 5 highest paid employees from the Employees table. Which SQL statement correctly creates this view?

hard📝 Application Q8 of 15
SQL - Views
You want to create a view that shows only the top 5 highest paid employees from the Employees table. Which SQL statement correctly creates this view?
ACREATE VIEW TopPaid AS SELECT * FROM Employees ORDER BY salary DESC LIMIT 5;
BCREATE VIEW TopPaid AS SELECT * FROM Employees WHERE salary > 5;
CCREATE VIEW TopPaid AS SELECT TOP 5 * FROM Employees ORDER BY salary ASC;
DCREATE VIEW TopPaid AS SELECT * FROM Employees WHERE ROWNUM <= 5 ORDER BY salary DESC;
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct syntax for limiting rows

    In standard SQL and many systems, LIMIT 5 after ORDER BY gets top 5 rows.
  2. Step 2: Check ordering and filtering

    Ordering by salary DESC ensures highest salaries first; LIMIT 5 picks top 5.
  3. Final Answer:

    CREATE VIEW TopPaid AS SELECT * FROM Employees ORDER BY salary DESC LIMIT 5; -> Option A
  4. Quick Check:

    Use ORDER BY DESC with LIMIT for top N rows [OK]
Quick Trick: Use ORDER BY DESC and LIMIT to get top N rows in views [OK]
Common Mistakes:
MISTAKES
  • Using WHERE salary > 5 which is unrelated
  • Using TOP 5 syntax which is not standard SQL
  • Incorrect order of clauses causing errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes