forum.venkateswarlu.net
      Register      Login
Display Employee total in Footer Using SQL Query

1 replies to this topic

Kalyan Suman #1
Member
150 Points
Posted on 27 Oct 2014 07:51 PM IST

 i have 2 tables Emp,Dept ; i want to dispaly department wise employees count and total employees

 Ex: Id  Name EmpCount
      -------------------------------
      1   IT            5
      2  HR          10
    ----------------------------
   Total ----------15

 
SQL Server     796 views     Reply to this topic
Cherukuri Venkateswarlu #2
Member
140 Points
Replied on 27 Oct 2014 11:25 PM IST Hi Kalyan,

You can use the below query to show the department wise employees count.

SELECT d.DeptID, d.DeptName, ISNULL(Count(e.EmpID),0) AS Employees
FROM tbl_Dept
d with (nolock)
LEFT JOIN
tbl_Emp e with (nolock) ON d.DeptID = e.DeptID
GROUP BY
d.DeptID, d.DeptName

If you want t add to total count in FOOTER, you sum all the grid rows, and can display in footer.
Hope this will helps.

Venkat
 
Reply to this topic