当前位置:编程学习 > 网站相关 >>

count(distinct xxx) 与distinct

select a,b,c

select a,b,distinct c   不对 distinct必须是对所有字段排重,必须写在外面。

select distinct a,b,c

 

 

 

第二种   也叫转置   主要理解意思

select a,count(distinct b) ....group by a


按照a,汇总不同的b。

 

 

 

1    1

1    2

1    3

1    2

汇总后:

1   3


 

补充:综合编程 , 其他综合 ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,