I’m trying to convert this table
ID TestID Elapsed ActionID
===================================
1 1 16 a1
2 1 17 a2
3 1 13 a3
4 1 14 a4
5 2 19 a1
6 2 21 a2
7 2 11 a3
8 2 22 a4
To this
TestID a1 a2 a3 a4
======================================
1 16 17 13 14
2 19 21 11 22
is this possible?
Yes, if there is only one action id for each testid
There is the pivot operator that Ajoe mentioned, but I think the traditional
syntax is easier to understand (if not immediately obvious).
You group rows by testid, so you will get one row of results
per each testid. What you select is the “max” in each group where the acitionid is a certain one. Or the min, or the average, or the sum – this is
predicated on there being only one item in each group.