New to MYSQL. I’m trying to create a query that essentially selects employees who have mentored more than 2 people. The mentored_by column uses the SSN of employee’s to tell who has mentored who, So you can see that that a couple of the SSNs in the SSN column match some of the SSNs in the mentored_by column. (Ignore the one value is that is null because I simply made it that he didn’t have a mentor).
How would I go about creating a query where it selects employees who have mentored more than 2 people (aka if theres the same SSN in multiple rows in mentored_by column)
2
Answers
Something like this, I presume:
Aggregate your data per mentor and count. With the found mentors select their rows from the employee table.
For your sample data, you will get the first row (Henry), because he mentored three persons (Jennie, Harold, Jameson).