title: Convert rows into columns without using PIVOT or Cased Aggregate Functions
body: <p>I have a table named customers in my database which has retailers(customers)
  and distributors seperated by typeid (Eg: typeid=1 customers and typeid=2 distributors)</p>
  
  <p>Now there is mapping table in which there are mappings of customers and distributors.
  Note that a Retailer or Customer will at most have only two distributors.</p>
  
  <p>Below is the Mapping table.    </p>
  
  <pre><code>| Customer    | Distributor  |
      ----------------------------
      |   Customer1 | Distributor1 | 
      |   Customer1 | Distributor2 |  
      |   Customer2 | Distributor1 |  
      |   Customer2 | Distributor3 |  
      |   Customer3 | Distributor2 |
  </code></pre>
  
  <p>I want to represent this table as follows </p>
  
  <pre><code>| Customer    | Partner1     | Partner 2     |
  ---------------------------------------------------
  | Customer1   | Distributor1 | Distributor2  |
  | Customer2   | Distributor1 | Distributor3  |
  | Customer3   | Distributor2 | Null          |
  </code></pre>
  
  <p>the concept of Pivot  struck me but there is no column to perform aggregate function on for pivot to be applied. </p>
  
  <p>Any simple ways to attain the desired result?</p>
  
  <p>PS: I have already thought of getting two different sets from two temp tables and then join them, but that looks to be tedious.Help me if some one could point me towards the result with a simpler solution .</p>