How does distinct work with the following table:
id | id2 | time
-------------------
1 | 5555 | 12
2 | 5555 | 12
3 | 5555 | 33
4 | 9999 | 44
5 | 9999 | 44
6 | 5555 | 33
select distinct * from table
If you use select distinct * from table
all the row are distinct
if you use
select distinct id2 , time from table
then you obtain
id2 | time
5555 | 12
5555 | 33
9999 | 44
With distinct you obtain the distinct rows based on the result of the select
此处的每一行都是不同的,因此distinct
将没有可见的效果,并且所有行都将被返回。
Select Distinct ID2 From SomeTable
将返回5555 9999
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.