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?
 
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
0
 
StephenCairnsCommented:

order by Job_title,  Exempt_non_exempt_status, last names ,  salary
0
 
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
0
 
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.