please help with my assignment on simple mysql queries
We have to build an EMP table with ten rows that illustrate the operation of these queries, and a DEPT table with five rows, with one department that has no employees assigned to it.
pLEASE HELP WITH SINGLE SELECT STATEMENT
1. List each employee and the other employees who earn more than that employee.
2. List the name of each employee and the percent of total company payroll that is earned by that employee.
1) I highly doubt any of us would do your homework for you.
2) You can't expect us to even consider it without knowing how the table's constructed (ie the columns, the keys, relations, etc)
Ok to answer your question then, based on your tables:
1) is only applicable if you pass a particular user, like you can find everyone that makes more than person #2 and that would be:
SELECT ename FROM employee WHERE salary > (SELECT salary FROM employee where eno = 'your_input') ORDER BY salary desc;
2) this should be:
select ename, salary / (select sum(salary) FROM employee) from employee;
you might need to fix some syntax errors. but check on the phrasing of question 1, as it is not something done in MySQL.
Bookmarks