select count(*) from (select uid from oc_commission group by uid) as uid
select count(*) from (select uid from oc_commission group by uid) as uid
Your sql can be optimized and it can be done in one sentence
select count(distinct(uid)) from oc_commission
tp:
M('Commission')->count(distinct(uid));
You can directly query using native code
http://www.kancloud.cn/manual/thinkphp/1775 The manual has subqueries, please take a look at it
$sql=M('oc_commission')->field('uid')->group(' uid')->select(false);
$count=M('oc_commission')->table($sql.' a')->count()
If an error is reported, go to github to download the latest version. An error will be reported