fuzao1314(提问者)SELECT
a.orgname,
substr(`a`.`EXETIME`, 1, 10) AS `ZYEAR`,
count(distinct EXETIME,orgid) as num
FROM
(
SELECT
*
FROM
sys_audit d
where d.orgId in (
SELECT s.ORGID from sys_org s
)
) as a
ORDER BY ZYEAR
这样最后只出来了一个结果,但是我有很多不同的数据,没有分别统计
axing 回复 fuzao1314(提问者)SELECT
a.orgname, substr(`a`.`EXETIME`, 1, 10) AS `ZYEAR`,
count(distinct EXETIME,orgid) as num
FROM ( SELECT * FROM sys_audit d where d.orgId in ( SELECT s.ORGID from sys_org s ) ) as a
group by a.orgname, substr(`a`.`EXETIME`, 1, 10)
ORDER BY ZYEAR