0

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 
AFetter
  • 2,940
  • 6
  • 33
  • 57

1 Answers1

1

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
Tim Biegeleisen
  • 451,927
  • 24
  • 239
  • 318