Recommended Answers
Jump to PostTry something like this.
SELECT DISTINCT emp.Job_ID, a.Employee_ID, a.Last_Name FROM Employees emp Join (Select job_id,employee_id,Lastname From Employees)a on emp.Job_id = a.Job_id ORDER BY a.Last_Name
Jump to PostI'm not quite sure what you are trying to achieve.
If you just want the job_id then grab it seperately, if you want to see all the employees associated which each job_id you have to return all rows for each job_id, unless you have exact duplicate rows which would …
Jump to PostI know it is possible as I have done similar queries in the past using subqueries. I provided something I put together quickly, not a very good example but it does accomplish what you were inquiring about.
select distinct a.JOB_ID, (Select EMPLOYEE_ID from EMPLOYEE b where b.JOB_ID …
Jump to Postif Employee_ID and Last_Name can be any, within a specified Job_ID,
You can also use the group functions, egSELECT Job_ID, max(Employee_ID), max(Last_Name) FROM Employees GROUP BY Job_ID
All 15 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.