title: How to pivot multiple columns without aggregation
body: <p>I use SqlServer and i have to admit that i'm not realy good with it ...
  This might be and easy question for the advanced users (I hope)</p>
  
  <p>I have two tables which look like this</p>
  
  <p>First table (ID isn't the primary key)</p>
  
  <pre><code>ID      IdCust   Ref
  1       300      123
  1       300      124
  2       302      345
  </code></pre>
  
  <p>And the second (ID isn't the primary key)</p>
  
  <pre><code>ID     Ref      Code    Price
  1      123      A       10
  1      123      Y       15
  2      124      A       14
  3      345      C       18
  </code></pre>
  
  <p>In the second table, the column "Ref" is the foreign key of "Ref" in the first table</p>
  
  <p>I'm trying to produce the following output:</p>
  
  <p><img src="https://i.stack.imgur.com/Ws77m.png" alt="The result what i want"></p>
  
  <p>[EDIT]
  The column "Stock", "Code" and "Price" can have x values, so I don't know it, in advance...</p>
  
  <p>I tried so many things like "PIVOT" but it didn't give me the right result, so i hope someone can solve my problem ...</p>