distinct和group by的区别
这两者本质上应该没有可比性,distinct 取出唯一列,group by 是分组,但有时候在优化的时候,在没有聚合函数的时候,他们查出来的结果也一样。
一、group by
英 [ɡru:p bai] 美 [ɡrup baɪ]
[计][WIN]分组依据
拓展资料
1、This operator also serves as input to the Group By operator.
该操作符还充当Group By操作符的输入。
2、Complete the following steps to create and program the Group By operator.
完成以下步骤,创建Group By操作符并对它进行配置。
3、With the appropriate access path, the ORDER BY or GROUP BY requirement can be met without sorting.
使用恰当的访问路径,无需排序即可满足ORDER BY或GROUP BY需求。
4、Drag it to the right of the Group By operator.
将它拖放到兆信Group By操作符的右边。
二、distinct
英 [dɪˈstɪŋkt] 美 [dɪ派纳ˈstɪŋkt]
adj.明显的,清楚的;卓越的,不寻常的;有区别的;确切的
拓展资料
1、I have distinct memories of him in his last years.
我清楚地记得他最后几年的情况。
2、Another Cup marathon between the two sides is now a distinct possibility.
双方很可能再进行一场马拉松式的优胜杯比赛。
3、The photograph showed a distinct image.
照片显出了族羡轮明晰的影像。
4、I want a distinct answer to my question.
我要求对我的问题作出明确的答复。
2016-08-14 · 知道合伙人教育行家
group by表示分组依据,依据......分组。
二者在意思上有较大的区别。
例句:
distinct
1、Engineering and technology are disciplines distinct from one another and from science.
工程学和工艺学互不相同,也有别于自然学科。
2、Now that Tony was no longer present, there was a distinct change in her attitude.
由于托尼不在场了,她的态度有了明显的转变。
3、Being 6ft 3in tall has some distinct disadvantages!
身高6英尺3英寸腔丛有些明显的不便之处!
4、There's a lot of evidence that oily fish, as distinct from fatty meat, has a beneficialeffect.
有许多证据表明油性鱼,与高脂肪肉不同,对人体有益。
group by
1、You could get ejected from the group by the moderators.
你可能会被管理员逐出该组织。备游
2、You can contribute to a new palette group by typing in another palette group name.
您可以通过键入另一个工具板名称来促成一个新工具板组。
3、But she was gradually forced into a close association with the Franco-Russiangroup by the aggressive development of a great German navy.
但是,由于德国积极发展了一支强大的海军,大不列颠被迫逐渐形成与法俄集团的紧密联系。
4、This style emphasizes the importance of team work, and creates harmony in a group by connecting people to each other.
这种风格强调团队合作的重要性,并通过让人们彼此联系来营造团队中的和谐气氛。
distinct只是将重复的卜孝帆行从结果中出去;
group by是按指定的列分组,一般这时在select中会用到聚合函数。
distinct是把不同的记录显示出来。
group by是在查询时先把纪录按型雹照类别分出来再查询。
group by 必须在查询结果中包含一慎洞个聚集函数,而distinct不用。
--每个部门有多少钱
select sum(钱),部门 from table
group by 部门
结果:部门1 130
部门2 100
--把相同的记录不显示出来,只选择此两列唯一的
select distinct 部门,钱 from table
结果:部门1 100
部门1 15
部门2 100
--而实际此表存在的记录如下:select * from table
结果:部门1 100
部门1 15
部门1 15
部门2 100
仔细比对一下,就清楚了。