title: Get number of employees who worked in more than one department with SQL query
body: <p>I'm trying to figure out a query which show the <strong>number</strong> (amount) of employees who worked in more than 1 departments. Here the table name and fields:</p>
  
  <ul>
  <li><code>Employee</code>(id_employee, employee_name, salary) </li>
  <li><code>Department</code>(id_dept, dept_name, budget) </li>
  <li><code>Department_Employee</code>(id_employee, id_dept, workhours_percentage)</li>
  </ul>
  
  <p>Suppose the content of Department_Employee table is</p>
  
  <pre><code>id_employee  id_dept  workhours_percentage
  -----------  -------  --------------------
  0001           03         100
  0001           04          50
  0001           05          60
  0002           05          60
  0002           09          90
  0003           08          80
  0004           07          80
  0005           06          60
  0006           05          70
  0007           04          75
  0008           10          95
  0009           02          25
  0010           01          40
  </code></pre>
  
  <p>With a right query, the result should be 2 (employees), because there are 2 employees who work in more than one department</p>
  
  <ul>
  <li>Employee 0001 work in 3 departments </li>
  <li>Employee 0002 work in 2 departments</li>
  </ul>
  
  <p><br>
  I tried with the following query</p>
  
  <pre><code>SELECT COUNT(DISTINCT id_employee)
  FROM Department_Employee
  GROUP BY id_employee
  HAVING COUNT(id_employee)&gt;1
  </code></pre>
  
  <p>But the result isn't right.</p>
  
  <p>Please help me out.</p>
  
  <p>Thanks.</p>