I have a database table with employees (emp) with colomns name and salary. By using an inline view query i would like to list name, salary and a new colomn with each employees % of the total salary of all employees (salary/tot_sal*100). I am having trouble understanding the use of views. I tried the following code, but it did not work. Any ideas?
create view tot_sal as
select sum(sal);
select name, salary, salary/tot_sal*100
from tot_sal
You have SELECT twice and a semi-colon. The name for the view cannot be the same as the table. You have to name each column. Try the following