标签:
1.sqlite> SELECT e.e_name, MAX(e.e_age), d.name FROM employee e
...> INNER JOIN dept d ON e.e_dept_id=d.id
...> GROUP BY e.e_dept_id;
2.sqlite> SELECT SUM(e.e_salary), d.name FROM employee e
...> INNER JOIN dept d ON e.e_dept_id=d.id
...> GROUP BY e.e_dept_id;
3.sqlite> SELECT e.e_dept_id, d.name FROM employee e
...> INNER JOIN dept d ON e.e_dept_id=d.id
...> GROUP BY e.e_dept_id
...> HAVING SUM(e.e_salary)>8000;
4.sqlite> SELECT d.id, d.name FROM dept d
...> WHERE d.id NOT IN
...> (SELECT e.e_dept_id FROM employee e);
5.sqlite> SELECT * FROM employee e
...> ORDER BY e.e_dept_id ASC, e_time ASC;
1.sqlite> SELECT d.dept, AVG(s.salary) FROM dept d
...> INNER JOIN employee e ON d.name=e.name
...> INNER JOIN salary s ON e.id=s.id
...> GROUP BY d.dept
...> ORDER BY AVG(s.salary) DESC;
2.sqlite> SELECT d.dept, s.id, e.name, MAX(s.salary) FROM dept d
...> INNER JOIN employee e ON d.name=e.name
...> INNER JOIN salary s ON e.id=s.id
...> GROUP BY d.dept;
标签:
原文地址:http://www.cnblogs.com/micele/p/4812838.html