Introduction
Views let you look at data like a saved question. You can ask the view for data without writing the full question again.
Jump into concepts and practice - no test required
SELECT column1, column2 FROM view_name WHERE condition;
SELECT * FROM employee_view;
SELECT name, salary FROM employee_view WHERE salary > 50000;
SELECT COUNT(*) FROM employee_view;
CREATE VIEW employee_view AS SELECT id, name, department, salary FROM employees WHERE active = 1; SELECT name, department FROM employee_view WHERE salary > 60000;
SELECT * FROM view_name; works because a view is:employee_view showing all columns from employees table?high_salary defined as:CREATE VIEW high_salary AS SELECT name, salary FROM employees WHERE salary > 70000;
SELECT * FROM high_salary WHERE salary > 80000;
CREATE VIEW dept_count AS SELECT department, COUNT(*) AS emp_count FROM employees GROUP BY department;
active_customers that shows customers with at least one order in the last 30 days.customers(id, name)orders(id, customer_id, order_date)