By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,414 Members | 1,586 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,414 IT Pros & Developers. It's quick & easy.

SQL--- GROUP BY Clause

P: n/a
jim
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.

Mar 21 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 20 Mar 2006 19:47:50 -0800, "jim" <ja**************@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 ***
Mar 21 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.