SQL question and query result

SQL question and query result

am 21.09.2007 07:14:07 von stevenleongusa

I am new to this SQL. Can someone answer this question for me?
1. Given the following schema of an employees table:


*employees (*

* empid integer primary key, -- employee id number*

* dept string, -- the employee's department number*

* salary float, -- salary of the employee*

* mgrid integer -- employee id number of employee's
manager*

*)*


Write the query (or queries if necessary) needed to count the number
of employees in each employee's department who are paid more than
their manager.
All employees (including managers) appear in this table.
Each employee has a manager (except the CEO), and the mgrid in the
employee's row is the empid of the employee's manager.

Re: SQL question and query result

am 21.09.2007 12:59:41 von Paul Lautman

stevenleongusa@gmail.com wrote:
> I am new to this SQL. Can someone answer this question for me?
> 1. Given the following schema of an employees table:
>
>
> *employees (*
>
> * empid integer primary key, -- employee id number*
>
> * dept string, -- the employee's department number*
>
> * salary float, -- salary of the employee*
>
> * mgrid integer -- employee id number of employee's
> manager*
>
> *)*
>
>
> Write the query (or queries if necessary) needed to count the number
> of employees in each employee's department who are paid more than
> their manager.
> All employees (including managers) appear in this table.
> Each employee has a manager (except the CEO), and the mgrid in the
> employee's row is the empid of the employee's manager.

It's your homework question, you are supposed to learn how to do it, not ask
us!