Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
jonjsilver2
Starting Member
14 Posts |
Posted - 2011-08-30 : 10:30:23
|
| I'm just being braindead and maybe someone can help. I have the following tables: Employee Empid EmpName EmpDoB employeeDepend empid DepName DepDoB DepartmentEmployees DeptId EmpId Department DeptId DeptName I would like the following info returned EmpId, EmpName, DeptName, NumberofDependents, Where the number of dependents for the employee > 2 Can someone help me with the query?thanks!jon |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-30 : 10:46:20
|
| [code]SELECT e.Empid,e.EmpName,ed.DepName FROM Employee eINNER JOIN employeeDepend edON ed.empid = e.empidINNER JOIN (SELECT empid,COUNT(DepName) AS DeptCnt FROM employeeDepend GROUP BY empid)ed1ON ed1.empid = ed.empidWHERE ed1.DeptCnt > 2[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|