问题:What are the different channels used by account id 1001? Your final table should have only 2 columns: account name and the different channels. You can try SELECT DISTINCT to narrow down the results to only the unique values.
要求排除表中的重复值,需要使用DISTINCT关键字
不使用DISTINCT时:
![](https://i-blog.csdnimg.cn/blog_migrate/cde0e2659988cca97c72f66a7d030ba5.png)
SELECT DISTINCT 列名称
FROM 表名称
声明后表中将不包含重复值,由于指定的account.id是1001,不同值只有channel
使用DISTINCT之后,可以去除掉重复值,比如上图中的DIRECT只保留一个,如图所示。
![](https://i-blog.csdnimg.cn/blog_migrate/f8903ea16bca1afb514d98f33a2e854f.png)