 <p>Try this if only 'ABC' an 'XYZ' types exist in the table:</p> <pre><code>SELECT number as id, MAX(CASE WHEN Type = 'ABC' THEN Date ELSE NULL END) as T1, MAX('ABC') as Type_1, MAX(CASE WHEN Type = 'XYZ' THEN Date ELSE NULL END) as T2, MAX('XYZ') as Type_2 FROM T GROUP BY Number </code></pre>