I have three tables
1.Nomination Nom
2.Calender cal
3.Employee emp
from Nom table i have to select cal_id,Emp_id
Then using cal_id from Nom i have to select program_name,Date from calender
Then again Using Emp_id from from Nom i have to select Emp_name, Dept_id,Desn_id from Employee then using dept_id,desn_id i have to select their name from their dept master table and desn master table and atlast i should use group by dept_name
Please somebody help me to write query for this.
my query is
select E.Dept_Name,E.Emp_name,E.Desn_Desc, C.[Training Name],C.From_Date,C.To_Date,C.[Training Mandays]
from
(select Dept_Name,Emp_name,Desn_Desc from HR_Mst_Employee Emp inner join HR_Mst_Department Dept on Dept.Id = Emp.Dept_id
inner join HR_Mst_Designation Desn on Emp.Desg_id = Desn.id
where Emp.id in(select Emp_id from HR_Trn_Nomination)) E,
(select cal.Program_name as 'Training Name',cal.From_Date,cal.To_Date,DATEDIFF(day,From_Date,To_Date)
as 'Training Mandays' from HR_Trn_Calender cal where id in
(SELECT Nom.Calender_id FROM HR_Trn_Nomination Nom)) C
i have selected all the columns but i dont know how to use groupby department_name