views:

65

answers:

1

This is part of a homework assignment. I've got several questions asking find the eid of the employee with the highest salary, or 2nd highest salary. Find the pilot that is certified for the most aircrafts. I don't have any idea on how to do it. There aren't any examples in the chapter, and google is proving less that helpful. If someone could show me how to do just one of these, it'll help a lot.

here are the tables:


Aircraft( aid: integer, aname: string, cruisingrange: integer )

Certified( eid: integer, aid: integer )

Employees( eid: integer, ename: string, salary: int )


+1  A: 

I can give you an hint in how to obtain max and min values:

think about the fact that you can join an entity over itself, now think what join criteria you could use.. and then you can use the result of the join to subtract results from your initial set of elements

EDIT: what happens if you join employers with them selves with a criteria of having first salary <= second salary?

Jack
@Jack: +1 for teaching to fish.
Eric J.
I can still only think of a temp variable or something. It might be a little easier if we did anything like this in class, or even if the book had covered it.
Justen
@EDIT: ok, I understand that logic. Get everyone who doesn't have the highest one, and the set difference operator. Now I guess I just need to figure out how to write it.
Justen