数数和明显的数量 [英] Count and distinct count

查看:116
本文介绍了数数和明显的数量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有简单的查询,其中为特定用户检索不同化学家ID的计数。





如果我写 - > count(distinct(chemist_id)) - >它返回= 1 [这里chemist_id = 0]

如果我写 - > count(chemist_id) - >它返回= 9(9次用户添加其他化学家详细信息(未注册化学家详细信息))



如果id'为0,则独立计数= 1



请告诉我怎么可能?

I have simple query in which count of distinct chemist id is retrieved for particular user.


if i write -> count(distinct(chemist_id)) -> it returns= 1 [here chemist_id=0]
if i write -> count(chemist_id) -> it returns= 9 (9 times user add other chemist details(not registered chemist details))

how distinct count=1 if id''s are 0

Please tell me how it is possible?

推荐答案





计数(chemist_id) - 返回表格中的行数



count(distinct chemist_id) - 返回不同(或唯一)chemist_id的计数。这意味着表中的所有行都具有相同的chemist_id。
Hi,

Count(chemist_id) - returns count of rows in the table

count(distinct chemist_id) - returns count of distinct (or unique) chemist_id. Which means all rows in the table have same chemist_id.


- 为了更好地理解 -



Chem_id(0,0 ,0,0,1,1,1,4,4,4,4,4)

计数(Chem_id)= 12

计数(不同(Chem_id)) = 3(此处为0,1,4)
-- For Better Understanding--

Chem_id (0,0,0,0,1,1,1,4,4,4,4,4)
Count(Chem_id)=12
Count(Distinct(Chem_id))=3 ( Here 0,1,4)


这篇关于数数和明显的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆