Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I’m facing a problem I want result like this please help me
I’m able to count the number of employees in a department but I can’t show as I want
Thanks in advance

Tbl_Dept
Dept_ID	Dept_Name
1	.NET
2	Java
3	Php

Tbl_Emp
Emp_ID	 Dept_ID	Emp_Name
1	 1	        Ram
2	 2	        Mohan
3	 3	        Sohan
4	 2	        Reeta
5	 3	        Sonu
6	 1	        Karan

Result
Dept_Name	Employees
.NET		Ram,Karan
Java		Mohan,Reeta
Php		Sohan,Sonu
Posted
Updated 29-Mar-14 10:38am
v2
Comments
Bala-Seequel 27-Mar-14 2:59am    
Ithink almost not possible to get output as u want, instead can get only in normal form as

dept_id emp_nmae
1 Ram
2 Mohan
3 Sohan
2 Reeta
3 Sonu
1 Karan

SQL
select emp_id, emp_name, dept_name
from tbl_emp
inner join tbl_Dept on tbl_Dept.Dept_id = tbl_emp.emp_id
 
Share this answer
 
Comments
CHill60 29-Mar-14 16:53pm    
If you had tested this you would realise that it produces
emp_id emp_name dept_name
1 Ram .NET
2 Mohan Java
3 Sohan Php

Which is not what the OP wanted
 
Share this answer
 
v2

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