数据库代码
1、给一个person表,有id,email,查找不重复的按照id排序
Select distinct email from person order by asc
2、用一条sql语句查询出“每门”课程都大于80分的学生姓名
用distinct还可以用not in 或者 not exists 实现
//not in
SELECT DISTINCT A.name FROM Student A WHERE A.name not in(SELECT Distinct S.name FROM Student S WHERE S.score <80);
//not exists
SELECT DISTINCT A.name From Student A where not exists (SELECT 1 From Student S Where S.score <80 AND S.name =A.name);
select name from (select name,min(score) from student group by name having min(score)>80) stu