Countof External Employees Under Each Manager

Puspanjali
New Contributor
New Contributor

 

Hi Team,

I'm trying to extract a report to know the count of external employees under each manager.

This is the query I'm using, but it is throwing some "count does not exist" errors.

Can team help me with this to fix it?

 

SELECT
m.username,
m.FIRSTNAME,
m.LASTNAME,
COUNT (u1.username) AS 'number_of_Externalemployees'
FROM users u1 INNER JOIN users m ON u1.owner= m.username
where u1.EMPLOYEETYPE = 'External'
GROUP BY m.username;

 

 

Puspanjali_0-1674221099956.png

 

1 REPLY 1

sk
All-Star
All-Star

Try below query

SELECT
m.username,
m.FIRSTNAME,
m.LASTNAME,
COUNT(u1.username) AS 'number_of_Externalemployees'
FROM users u1 INNER JOIN users m ON u1.owner= m.username
where u1.EMPLOYEETYPE = 'External'
GROUP BY m.username;


Regards,
Saathvik