1.作用于单列
select distinct name from A
SELECT DISTINCT 列名称 FROM 表名称
2.作用于多列
示例2.1
select distinct name, id from A
3.COUNT统计
select count(distinct name) from A;
4.distinct必须放在开头
select id, distinct name from A; --会提示错误,因为distinct必须放在开头
select distinct name from A
SELECT DISTINCT 列名称 FROM 表名称
示例2.1
select distinct name, id from A
select count(distinct name) from A;
select id, distinct name from A; --会提示错误,因为distinct必须放在开头