Average tenure: Statistics for a manager's tenure
P粉898049562
2023-08-13 11:54:57
<p>Recruiting teams want to know how long managers have been in their roles. </p>
<p>Retrieves the average length of time managers have been in a position. </p>
<p>Please write a query to retrieve the required data in the stored procedure. </p>
<p>Table name = employee, you can check the table by running a query like <code>select top 10 * from employee</code> and press "Return Value" to see the results. </p>
<p>manager_id refers to the employee’s direct manager. </p>
<p>Do not round the result (it needs to match the numbers in the expected output), make sure to give the column a name in the query output, such as time_in_position. </p>
<table class="s-table">
<thead>
<tr>
<th>mployee_id</th>
<th>manager_id</th>
<th>name</th>
<th>time_in_position</th>
</tr>
</thead>
<tbody>
<tr>
<td>8</td>
<td>9</td>
<td>Michael Kim</td>
<td>6.20</td>
</tr>
<tr>
<td>34</td>
<td>35</td>
<td>Peter Tan</td>
<td>4.00</td>
</tr>
<tr>
<td>21</td>
<td>23</td>
<td>Alice Li</td>
<td>1.90</td>
</tr>
</tbody>
</table>
<p>Retrieves the average length of time managers have been in a position. </p>
I assume that your "employee" table has a column called "start_date" that represents the start date of the employee's position.