Transform or transpose table based on time using SQL?
<p>Suppose we have source tabular data in this format</p>

<blockquote>
  <p>Service,Time,Metric</p>
</blockquote>

<p>where time column has duplicate timestamp entries for different service metrics collected at same time. As such over time, there's repeating values under service, time, host, and metric (if it doesn't change much).</p>

<p>How might one transform or transpose the table into this format, normalizing against time. I know time might not match up across all service metrics, but let's naively assume it does.</p>

<blockquote>
  <p>Time,ServiceAMetric,ServiceBMetric,ServiceCMetric,etc.</p>
</blockquote>

<p>where the header field will list the service names, the rest of the rows contain the metric values</p>

<p>Is this something that can be done with SQL? Or one has to transform with scripting? If the latter, how might I do so? Most any scripting language will do for me.</p>

<p>In this particular case, the data is from CSV file and not tables in DB. For transformation, can keep output as a new CSV file.</p>