Group into exempt and non-exempt.

My question is how to Select the employees’ last names and group them by salary within job titles that are grouped into exempt and non-exempt.  

Employee
      Social_security_number      char
      Last_name                  varchar
      First_name                  varchar
      Address                  varchar
      City                        varchar
      State                  char
      Zip_code                  char
        Telephone_area_code      char            
      Telephone_number            char      
      Email_address            varchar      
      Job_title_code            varchar      
      Hire_date                  smalldatetime
      Salary                  money
                        
Job_title
      Job_title_code            varchar
      Job_title                  varchar
      Exempt_non_exempt_status  bit         (1-Exempt, 0-non-Exempt)      
      Minimum_salary            money
      Maximum_salary            money






mayan1Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Aneesh RetnakaranDatabase AdministratorCommented:
SELECT E.Last_Name, JT. Job_title_code , JT.Exempt_non_Exempt_status
FROM Employee E
Inner Join Job_Title
ON E. Job_title_code =JT. Job_title_code

GROUP BY E.Last_Name,JT. Job_title_code , JT.Exempt_non_Exempt_status

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
StephenCairnsCommented:

order by Job_title,  Exempt_non_exempt_status, last names ,  salary
Aneesh RetnakaranDatabase AdministratorCommented:
I forgot to put the aliase


SELECT E.Last_Name, JT. Job_title_code , JT.Exempt_non_Exempt_status
FROM Employee E
Inner Join Job_Title JT
ON E. Job_title_code =JT. Job_title_code

GROUP BY E.Last_Name,JT. Job_title_code , JT.Exempt_non_Exempt_status
LowfatspreadCommented:
SELECT case exempt_non_exempt_status when 1 then 'Exempt' else 'Non Exempt' end as [Status]
          , JT. Job_title
          , Salary
           ,Last_Name
FROM Employee E
Inner Join Job_Title JT
ON E. Job_title_code =JT. Job_title_code

order by 1,Job_title, Salary Desc,last_name

i think you are using the phrase GROUP BY by to indicate the ORDER in which you want the rows returned....
beware in SQL GROUP BY is used to indicate a summation/totaling activity and the ORDER BY clause is used
to determine the actual result order...

hth
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.