study Python 14day(mysql学习)
倒数第三个员工信息 SELECT * FROM employees ORDER BY hire_date DESC LIMIT 2,1; LIMIT m,n : 表示从第m+1条开始,取n条数据; LIMIT n : 表示从第0条开始,取n条数据,是limit(0,n)的缩写 薪资涨15次以上的 SELECT emp_no, COUNT(emp_no) AS t FROM salaries GROUP BY emp_no HAVING t > 15 去重当前薪资 SELECT DISTINCT salary FROM salaries WHERE to_date = '9999-01-01' ORDER BY salary DESC 不是经理的员工 SELECT emp_no FROM employees WHERE emp_no NOT IN (SELECT emp_no FROM dept_manager) title进行分组,显示大于2的组 SELECT title, COUNT(title) AS t FROM titles GROUP BY title HAVING t >= 2 同上,忽略重复的emp_no SELECT title, COUNT(DISTINCT emp_no) AS t FROM titles GROUP BY title HAVING t >= 2