字段合同是文本,值是用“,”分隔的字符串。
查询:
select sum( if( length(dapps.contracts) =
sum(length(replace(dapps.contracts,',',''))) , 1 , length(dapps.contracts)
- sum(length(replace(dapps.contracts,',',''))) ) ) as f1
from dapps
group by id
显示:
Error in query (1111): Invalid use of group function
需要一级查询
此查询工作正常
select sum(f1)
from (
select if( length(dapps.contracts) =
sum(length(replace(dapps.contracts,',',''))) , 1 , length(dapps.contracts)
- sum(length(replace(dapps.contracts,',',''))) ) as f1
from dapps
group by id
) tb1
需要查询而无需子查询