`
shendixiong
  • 浏览: 398558 次
  • 性别: Icon_minigender_1
  • 来自: 长沙
社区版块
存档分类
最新评论

Reference 'v1' not supported (reference to group function) 解决方案

阅读更多
SELECT
	pt.project_id,
	pt.project_name,
	ROUND(sum(allC), 2) v1,
	ROUND(sum(allF), 2) allF,
	(SELECT  v1) t
FROM
	project_tab pt
LEFT JOIN ts_company_arch tca ON pt.project_id = tca.project_id
LEFT JOIN ts_job_arch tja ON tca.arch_id = tja.arch_id
WHERE
	pt.state = 1
AND pt.area_id = 2
GROUP BY
	pt.project_id,
	pt.project_name

 其中allC 我取了别名 就会报错

 Reference 'v1' not supported (reference to group function)

 解决方案就是不要取别名或者取的别名也为allC,如下:

SELECT
	pt.project_id,
	pt.project_name,
	ROUND(sum(allC), 2) ,
	ROUND(sum(allF), 2),
	(SELECT allC) t
FROM
	project_tab pt
LEFT JOIN ts_company_arch tca ON pt.project_id = tca.project_id
LEFT JOIN ts_job_arch tja ON tca.arch_id = tja.arch_id
WHERE
	pt.state = 1
AND pt.area_id = 2
GROUP BY
	pt.project_id,
	pt.project_name

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics