mayan1
asked on
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I forgot to put the aliase
SELECT E.Last_Name, JT. Job_title_code , JT.Exempt_non_Exempt_statu s
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_statu s
SELECT E.Last_Name, JT. Job_title_code , JT.Exempt_non_Exempt_statu
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_statu
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
, 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
order by Job_title, Exempt_non_exempt_status, last names , salary