Prompt Detail:
You can achieve this by using the `UNION ALL` operator in T-SQL to combine the results of three separate queries. Each query will extract one of the values (CST, SRF, or IRF) from the original row and create a new row with the same ScanId and Filename.
Here is an example query that should accomplish what you're looking for:
```
SELECT ScanId, 'CST' AS Metric, CST AS Value, Filename
FROM your_table
UNION ALL
SELECT ScanId, 'SRF' AS Metric, SRF AS Value, Filename
FROM your_table
UNION ALL
SELECT ScanId, 'IRF' AS Metric, IRF AS Value, Filename
FROM your_table;
```
In this query, we first select the ScanId, 'CST' as the Metric (to indicate which value we are selecting), the value of CST, and the Filename from your_table. We then use the `UNION ALL` operator to combine this result set with two additional result sets, one for SRF and one for IRF. In each of these result sets, we select the appropriate Metric and Value columns, but keep the same ScanId and Filename values.
This query will return a result set with three times as many rows as the original table, but with the same ScanId and Filename values repeated for each corresponding value of CST, SRF, and IRF.
Add a comment