www.webdeveloper.com
Results 1 to 8 of 8

Thread: please help with my assignment on simple mysql queries

  1. #1
    Join Date
    Feb 2006
    Posts
    4

    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.

  2. #2
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    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)
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  3. #3
    Join Date
    Feb 2006
    Posts
    4

    dnt be rude !

    Hi
    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.

  4. #4
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    I can't help you out if you don't tell me what the table looks like.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  5. #5
    Join Date
    Feb 2006
    Posts
    4

    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.

    where dept.deptno=employee.deptno


    i know, its simple, but i m realy stuck in this.

  6. #6
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    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.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  7. #7
    Join Date
    Feb 2006
    Posts
    4

    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?

  8. #8
    Join Date
    Aug 2005
    Location
    The Garden State
    Posts
    5,634
    I find this one good for newer people

    http://www.amazon.com/gp/product/076...Fencoding=UTF8
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles