1.别名:(1)查询的列名必须存在在where条件的列中,否则就需要起别名
(2)from里面的子查询需要设置别名,如
select id from (select min(id) as id from l_stu GROUP BY sid,name,cid,course,score) as a
(3)where里面的子查询不需要别名,如
select id from l_stu where id not in(select id from l_stu where score = 80)
(4)查询的字段来自子查询,如果子查询查出来的是聚合函数,那么要给聚合函数其别名,同时被查询的字段应该和
别名 保持一致
2.distinct用于返回唯一的不同的列值,就是去重用的,如果是多列必须是同时满足,必须放在开头
select distinct name from table;//选择重复姓名中的一个
select DISTINCT name from kecheng where name not in(select DISTINCT name from kecheng where fenshu<80)