联表查询:分组筛选
SELECT
e.emp_no,
MIN(s.salary)
FROM
employees e
INNER JOIN salaries s
ON e.emp_no = s.emp_no
GROUP BY e.emp_no
ORDER BY e.emp_no DESC
或者
SELECT
e.emp_no,
s.salary
FROM
employees e
INNER JOIN salaries s
ON e.emp_no = s.emp_no
GROUP BY e.emp_no HAVING MIN(s.from_date)
ORDER BY e.emp_no DESC联表查询:hire_date和dorm_date对应
SELECT
e.emp_no,
s.salary
FROM
employees e
INNER JOIN salaries s
ON e.emp_no = s.emp_no
WHERE e.hire_date=s.from_date
order by e.emp_no desc
京公网安备 11010502036488号