- #1
- 7,003
- 10,423
My apologies in advance: I have tried to install MSSQL2014 many times unsuccessfully (I get a bunch of .zip files, but no executable) so I cannot test my queries. I looked for places to " outsource" my queries, I was told of MySql fiddle , but I can't see how to run my database there. I am just going over a class video and trying to do things on my own and then check against the answer given. If someone knows of a public source for setting up databases and running queries, I would appreciate any ref.
Anyway, I have a table Employee containing , among others, EmpId and ReportsTo. I am trying to do a query to find out which employee has the most other employees reporting to them. I am using this subquery:
Select employeeID, Count(ReportsTo) from Employee
Group by employeeId having
Count(ReportsTo) >= (select max(Count(ReportsTo)) from employee group by EmpId)
The answer given basically swaps employeeID and ReportsTo.
I am trying to understand what I did wrong. Thanks for any comments.
Anyway, I have a table Employee containing , among others, EmpId and ReportsTo. I am trying to do a query to find out which employee has the most other employees reporting to them. I am using this subquery:
Select employeeID, Count(ReportsTo) from Employee
Group by employeeId having
Count(ReportsTo) >= (select max(Count(ReportsTo)) from employee group by EmpId)
The answer given basically swaps employeeID and ReportsTo.
I am trying to understand what I did wrong. Thanks for any comments.