我已经在 MySQL 中尝试了以下查询,但没有工作。
select count(*)
from (
select count distinct(RADL_REQUEST_MSISDN)
from rbt_activation_details_log
where RADL_ACTIVE ='A'
group by RADL_REQUEST_MSISDN
);
我已经在 MySQL 中尝试了以下查询,但没有工作。
select count(*)
from (
select count distinct(RADL_REQUEST_MSISDN)
from rbt_activation_details_log
where RADL_ACTIVE ='A'
group by RADL_REQUEST_MSISDN
);
select count(distinct column_whose_distinct_values_you_want_to_count)
from rbt_activation_details_log
where RADL_ACTIVE ='A'
group by RADL_REQUEST_MSISDN
您正在对同一列进行分组和计数,因此这将始终为您1
提供结果。
编辑:
然后简单地省略 group by 子句
select count(distinct RADL_REQUEST_MSISDN)
from rbt_activation_details_log
where RADL_ACTIVE ='A'
SELECT COUNT(DISTINCT RADL_REQUEST_MSISDN)
FROM rbt_activation_details_log
WHERE RADL_ACTIVE = 'A'
GROUP BY RADL_REQUEST_MSISDN;
SELECT Count(UNIQUE(radl_request_msisdn))
FROM rbt_activation_details_log
WHERE radl_active = 'A'
GROUP BY radl_request_msisdn
根据您的查询:
select count(*)
from
(select count distinct(RADL_REQUEST_MSISDN)
from rbt_activation_details_log
where RADL_ACTIVE ='A' group by RADL_REQUEST_MSISDN);
显示为您要检索未按 radl_request_msisdn 分组的所有不同计数。如果是这样,那么您以这种方式重写您的查询:
select count distinct(RADL_REQUEST_MSISDN)
from rbt_activation_details_log
where RADL_ACTIVE ='A';
相反,如果您想分组,查询将是:
select count distinct(RADL_REQUEST_MSISDN)
from rbt_activation_details_log
where RADL_ACTIVE ='A' group by RADL_REQUEST_MSISDN;