Sql问题,如何使用Count值显示更多名称 [英] Sql Problem,how can one more name show with the Count value
问题描述
这是我的Sql Query.it工作正常,Out put在下面显示是正确的
this is my Sql Query.it's working fine and Out put is correct below show
select COUNT(*) from tbl_Job_OrgOpeningDetail org
inner join tbl_job_Functional_Area fa on org.Role_type=fa.Funcational_id
where org.Role_type in (21,15) Group by org.Role_type
out put
out put
Column Name
2
3
但是我希望功能名称的名称显示为COunt值
我试试这个
but i Want Name of Functional Name show with the COunt Values
I am try this
select COUNT(*),fa.FuncationalArea from tbl_Job_OrgOpeningDetail org
inner join tbl_job_Functional_Area fa on org.Role_type=fa.Funcational_id
where org.Role_type in (21,15) Group by org.Role_type
但错误系统显示
像这样: -
But error system show
like this :-
Msg 8120,级别16,状态1,过程sp_job_ddlBindings,第48行
Msg 8120, Level 16, State 1, Procedure sp_job_ddlBindings, Line 48
Column 'tbl_job_Functional_Area.FuncationalArea' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
如何删除此错误..
谢谢< br $> b $ b
快乐问题☻
how can do remove this error..
Thanks
Happy Problem ☻
推荐答案
试试这个查询: -
Try this query:-
select COUNT(*),fa.FuncationalArea from tbl_Job_OrgOpeningDetail org
inner join tbl_job_Functional_Area fa
on org.Role_type=fa.Funcational_id
where org.Role_type in (21,15) Group by org.Role_type,fa.FuncationalArea
在group by子句中添加fa.FuncationalArea。您的查询应该如下所示
Add fa.FuncationalArea in group by clause. Your query should look like this
select COUNT(*),fa.FuncationalArea from tbl_Job_OrgOpeningDetail org
inner join tbl_job_Functional_Area fa on org.Role_type=fa.Funcational_id
where org.Role_type in (21,15) Group by org.Role_type, fa.FuncationalArea
这篇关于Sql问题,如何使用Count值显示更多名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!