If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Help! A tricky query problem.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-08-04, 00:04
oldersea oldersea is offline
Registered User
 
Join Date: Apr 2004
Posts: 10
Help! A tricky query problem.

I have this self-related table:

Employee:

SSN Name salary Manager
111 Jim 1000 222
222 Jack 3000
333 Jerry 2000 111
...

The query problem is: list the eployees' ssn and name whose salary is less than 3/5 of his managers:

I tried this one but always fails:

select a.ssn, a.name
from employee as a join employee as b on (a.manager=b.ssn)
where a.salary<(3/5)*b.salary;

A little bit confused, how can i build the self-related tables and make the query right?
Mnay thanks!!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On