I have a table tblEntrants
which is a list of pool players. I want to draw fixtures for them so I need to take the top half of the list and play them against the bottom half of the list by copying them into tblFixtures
.
tblFixtures
has 3 columns: player1, player2 and compID.
This is what I have so far:
INSERT INTO tblFixtures (player1, compID)
SELECT TOP (50) PERCENT
accountID, compID
FROM
tblEntrants
WHERE
paid = 'y' AND compID = @compID
ORDER BY
accountID ASC
INSERT INTO tblFixtures (player2)
SELECT TOP (50) PERCENT accountID
FROM tblEntrants
WHERE paid = 'y' AND compID = @compID
ORDER BY accountID DESC
But this does this...
Player1 Player 2 CompID
---------------------------
Bob v null {Guid}
Bill v null {Guid}
Ben v null {Guid}
null v Matt {Guid}
null v Mick {Guid}
null v Mark {Guid}
I need to adjust the above code to add the bottom half of the players in to the Player2 column where the first half of the players exist. Like this..
Player1 Player 2 CompID
---------------------------
Bob v Matt {Guid}
Bill v Mick {Guid}
Ben v Mark {Guid}
Any help appreciated