数据库 count 返回类型修改

原先数据库查询代码:

SELECT
	area_name,
	count(1)
FROM
	A03_CITIC_ENT_basic 
WHERE
	country_nam = #{mapName} 
GROUP BY
	area_name 
HAVING
	count( area_name ) >=1

{“a":"国家","count",20}

修改之后代码:

SELECT
	area_name,
	cast(count(1) as varchar) count
FROM
	A03_CITIC_ENT_basic 
WHERE
	country_nam = #{mapName} 
GROUP BY
	area_name 
HAVING
	count( area_name ) >=1

这个就可以正常的返回数据:

{“a":"国家","count","20"}

你可能感兴趣的