0

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 )


philipxy
  • 14,867
  • 6
  • 39
  • 83
Justen
  • 4,859
  • 9
  • 44
  • 68
  • If you're going to mark me down, at least tell me why. – Justen Mar 11 '10 at 22:24
  • do you have to build queries to obtain results? SQL-style? – Jack Mar 11 '10 at 22:28
  • 1
    My guess would be that the down-marker didn't realize that these math topics are actually important underpinnings of computer science. I think it's a worthy question and it sounds like you at least made an attempt yourself before asking here. – Eric J. Mar 11 '10 at 22:30
  • @jack - No not SQL style, but in the methods I put in my topic. @Eric - Yeah, I've done the 50 other ones we've had, but I'm just not sure what to do here. I can only imagine having a temp variable like in a C++ context – Justen Mar 11 '10 at 22:32

1 Answers1

5

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
  • 131,802
  • 30
  • 241
  • 343
  • 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 Mar 11 '10 at 22:35
  • @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 Mar 11 '10 at 23:37