Create Table Emp
(
EId Int primary key,
EName varchar(20)
)
Create Table Leavedetails
(
LId int,
NoOfDays int,
Emp_ID int foreign key references Emp(EId)
)
Group By
Select EName, Sum(NoOfDays) NoOfDays from Emp
Inner Join Leavedetails on Emp.EId=Leavedetails.Emp_ID
Group By EName
The column names after Select statement, should be member of Group By or Aggregate function (SUm, Avg, Count), other wise you will get error.