|
Posted by clare at snyder.on.ca on 03/21/06 06:09
On 20 Mar 2006 19:47:50 -0800, "jim" <jaycee74catbagan@yahoo.com>
wrote:
>Hi,
>
>I was wondering if anyone out there can help me with this SQL problem:
>
>
>I have a database that has two tables: EMPLOYEE and JOB_TITLE
>
>
>The EMPLOYEE Table consists of a salary and job_title _code columns,
>among many others; the JOB_TITLE table contains job_title_code column,
>among many others.
>
>
>The SQL problem is: Select the employees' last names and Group them by
>Salary within their job_title_code. I am new to SQL statements and
>kinda puzzled on how to solve this problem. I would appreciate any help
>
>I can get on this. Thanks a lot in advance.
select e.lastname, e.job_title_code, e.salary
from employee e, job_title t
Where e.job_title_code = t.job_title_code
order by 2,3,1
Will output name, jobtitle, and salary, ordered by jobtitle, salary,
and name - so all of one job title, sorted by salary, sorted by name,
followed by all of the next job title, sorted by salary, sorted by
name.
adams, shipper, 40,000
amos, shipper, 40,000
Bertrand, shipper, 40,000
zinger, shipper, 40,000
adamson, shipper, 39,000
zehr shipper, 39,000
sauer, shipper, 29,000
best, reciever,55,000
carlisle, reciever, 17,000
bauman, trucker, 42,000
harley, trucker, 41,000
etc
Can be simplified to:
select lastname, job_title_code, salary
from employee
order by 2,3,1
since all the data being requested is in the employee file.
*** Free account sponsored by SecureIX.com ***
*** Encrypt your Internet usage with a free VPN account from http://www.SecureIX.com ***
[Back to original message]
|