title: Sql Query to breakdown
body: <p>I have the following table structure in SQL Server</p>
  
  <p><strong>Transaction</strong>:</p>
  
  <pre><code> ---------------------------------------------------------------------
   **ID | FromEmployeeID | ToEmployeeID | OutgoingTotal | IncomingTotal**|
   ---------------------------------------------------------------------
     1  |      10        |     20       |       10      |       50
     2  |      11        |     10       |       20      |       40    
  </code></pre>
  
  <p>I need to transform this data in another table <code>Summary</code> by <code>employeeID</code>, as if a transaction started from an employee to an employee I have to enlist in summary as two records for each of employee (1 for from outgoing and one for incoming) </p>
  
  <p><strong>Summary</strong>:</p>
  
  <pre><code> ---------------------------------------------------------------------
   **ID | EmployeeID | outgoingcount| incomingcount | OutgoingTotal| IncomingTotal**|
   ---------------------------------------------------------------------
     1  |      10    |     1        |       1       |   10         |  50
     2  |      20    |     0        |       1       |   0          |  50
     3  |      11    |     1        |       0       |   0          |  40   
  </code></pre>
  
  <p>I also have the employee table in which employee id and other information of employee is there.</p>
  
  <p>How can this be accomplished? </p>