title: SQL Pivot to Return Distinct Values as Column Name
body: <p>I have a table column with this structure:</p>
  
  <pre><code>|------ ID ------|
  |-  1.20.10.00  -|
  |-  1.20.10.10  -|
  |-  1.20.10.20  -|
  |-  1.20.20.00  -|
  |-  1.20.20.10  -|
  |-  1.40.10.00  -|
  |-  1.40.20.00  -|
  |-  1.60.10.00  -|
  |-  1.60.10.00  -|
  </code></pre>
  
  <p>I am trying to run a query which will pivot the data into multiple columns based on the Distinct values returned by a string Like the 5 left characters in the value, the column names matching the 5 characters used in the like statement.  Let me show an example of what I want to get to:</p>
  
  <pre><code>|----- 1.20. ----||----- 1.40. ----||----- 1.60. ----|
  |-  1.20.10.00  -||-  1.40.10.00  -||-  1.60.10.00  -|
  |-  1.20.10.10  -||-  1.40.20.00  -||-  1.60.10.00  -|
  |-  1.20.10.20  -|
  |-  1.20.20.00  -|
  |-  1.20.20.10  -|
  </code></pre>
  
  <p>I'm on an Oracle 11g db, so I figured I should be using the PIVOT command, but I can't figure out how to set it up with the addition of the DISTINCT and LIKE commands.  Any help would be appreciated.</p>