第4节. 过滤数据
1.Select Distinct子句
select distinct子句检索指定列列表中的唯一不同值,换句话说,它从结果集中删除列中的重复值
distinct子句将所有 NULL 值视为相同的值
语法如下所示:
select distinct
column_name1,
column_name2 ,
...
from
table_name
A.distinct一个字段的示例
以下语句返回 customers 表中所有客户所在的所有城市(去重复):
select distinct
city
from
sales.customers
order by
city
B.distinct多列示例
以下语句查找所有客户的不同城市和州
select
city,
state
from
sales.customers