表员工:
╔═══════════════════════════════════════════════════╗
║ emp_id emp_position emp_start_date employer_id ║
╠═══════════════════════════════════════════════════╣
║ 1234 Associate 08/08/08 7657 ║
║ 1234 Associate 01/01/11 3345 ║
║ 1234 Manager 04/03/13 9483 ║
║ 1234 Manager 04/05/15 2345 ║
╚═══════════════════════════════════════════════════╝
如何构造查询以获取每个emp_role的最早日期,并且查询应仅返回持有多个帖子的员工。
选择smp.emp_id,smp.emp_position,smp.cnt(通过emp_id,emp_position选择emp_id,emp_position,count(*)作为来自员工组的cnt)smp其中smp.cnt> 1
答案 0 :(得分:3)
select
emp_position,
min(emp_start_date)
from
Employee
group by
emp_position
答案 1 :(得分:3)
尝试此查询
SELECT emp_position, MIN(emp_start_date)
FROM Employee
GROUP BY emp_position