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)
dnt be rude !
I knw how to construct table...and i already done the major part of this, its just that, i am not able to do this couple of queries.
I would appreciate if you can help me out in this.
I can't help you out if you don't tell me what the table looks like.
here is the table.
there is two table in the database:
1. employee (eno, ename, salary, dept no)
it has 10 rows
and other table is dept table:
dept (deptno, dname)
it has 5 rows.
i know, its simple, but i m realy stuck in this.
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.
please suggest me a book
thanks a lot, for this help.
Can u suggest me a good sql book or any online tutorial with lots of examples?
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)