1)查询成绩表中name重复的
select name from score group by name having count(*) > 1;
2)查询成绩表中name>2次,并且按照降序排列
select count(name) as '出现次数',name from score group by name having count(name) > 2 order by '出现次数' DESC
3)去重
select distinct name from score
4)找出成绩大于150的,并且按照降序排列
select * from score where salary > 150 order by salary DESC
5)范围查找
select * from 表名 where 字段名 [not] between 值1 and 值2;
select * from score where salary > 150 or (salary < 100 and salary > 60)
6)找出比平均成绩小的
select * from score where salary < (select avg(salary) from score)
7)查询初年龄最小的学生姓名
select name from score where age = (select min(age) from score)
8)
select e.name,e.department,e.salary, t.`平均成绩` from emp e,
(select department,AVG(salary) as `平均成绩` from emp GROUP BY department) t
where e.department = t.department and e.salary < `平均成绩`
9)