from d in Tbldepts
join e in Tblemps on d.Id equals e.DeptID
orderby d.DeptName
group e by new{d.DeptName,d.Id }into gt
select new{DeptID=gt.Key.Id,DeptName=gt.Key.DeptName,TotalSalary=gt.Sum(p=>p.Salary)}
SELECT SUM([t1].[salary]) AS [TotalSalary], [t0].[DeptName]
FROM [tbldept] AS [t0]
INNER JOIN [tblemp] AS [t1] ON ([t0].[Id]) = [t1].[DeptID]
GROUP BY [t0].[DeptName], [t0].[Id]
join e in Tblemps on d.Id equals e.DeptID
orderby d.DeptName
group e by new{d.DeptName,d.Id }into gt
select new{DeptID=gt.Key.Id,DeptName=gt.Key.DeptName,TotalSalary=gt.Sum(p=>p.Salary)}
SELECT SUM([t1].[salary]) AS [TotalSalary], [t0].[DeptName]
FROM [tbldept] AS [t0]
INNER JOIN [tblemp] AS [t1] ON ([t0].[Id]) = [t1].[DeptID]
GROUP BY [t0].[DeptName], [t0].[Id]
No comments:
Post a Comment