Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi,

this is my Sql Query.it's working fine and Out put is correct below show
SQL
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

SQL
Column Name
2
3


but i Want Name of Functional Name show with the COunt Values

I am try this

SQL
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 :-
Quote:
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.


how can do remove this error..
Thanks

Happy Problem ☻
Posted
Comments
Seema.Net 23-Dec-13 1:59am    
if u want to show fa.FuncationalArea put this with Group By
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


OR

select COUNT(*),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
joginder-banger 23-Dec-13 2:58am    
Thanks sir

Try this query:-
SQL
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
 
Share this answer
 
Comments
joginder-banger 23-Dec-13 2:57am    
Thanks buddy..,...
TrushnaK 23-Dec-13 3:18am    
welcome.
Add fa.FuncationalArea in group by clause. Your query should look like this

SQL
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
 
Share this answer
 
Comments
joginder-banger 23-Dec-13 2:58am    
Thanks Buddy
josephbhaskar 23-Dec-13 3:31am    
welcome.. let me know if u face any other issues

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900