Complex views

suggest change

A view can be a complex query (aggregations, joins, subqueries, and so on). Give every selected expression a column name:

Create VIEW dept_income AS
SELECT d.Name as DepartmentName, sum(e.salary) as TotalSalary
FROM Employees e
JOIN Departments d on e.DepartmentId = d.id
GROUP BY d.Name;

Now you can select from it as from any table:

SELECT * 
FROM dept_income;
DepartmentName TotalSalary
HR 1900
Sales 600

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents