if I have a table like this:
MatchCode | TransferId |
---|---|
17edce4d | 7 |
17edce4d | 17 |
20332cf0 | 22 |
20332cf0 | 30 |
is it possible make the result return this?
MatchCode | TransferId1 | TransferId2 |
---|---|---|
17edce4d | 7 | 17 |
20332cf0 | 22 | 30 |
if I have a table like this:
MatchCode | TransferId |
---|---|
17edce4d | 7 |
17edce4d | 17 |
20332cf0 | 22 |
20332cf0 | 30 |
is it possible make the result return this?
MatchCode | TransferId1 | TransferId2 |
---|---|---|
17edce4d | 7 | 17 |
20332cf0 | 22 | 30 |
If each MatchCode
group will always have only two records, then you can use the MIN
and MAX
along with a GROUP BY
:
SELECT MatchCode, MIN(TransferId) AS TransferId1, MAX(TransferId) AS TransferId2
FROM yourTable
GROUP BY MatchCode