数据库代码

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

 

posted @ 2020-07-23 14:57  我们村里的小花儿  阅读(243)  评论(0编辑  收藏  举报