Hi Jay,
You could use a couple queries (one for odd records and one for even) and
then combine them:
The following is SQL that would pull all the Even records while calculating
the "Pair" number using the Customer table from Northwind.
===qselEven=====
SELECT
(SELECT Count(*)
FROM Customers C
WHERE C.CustomerID<=Customers.CustomerID) Mod 2 AS OddEven,
(SELECT Count(*)
FROM Customers C
WHERE C.CustomerID<Customers.CustomerID)\2 AS Pair,
Customers.*
FROM Customers
WHERE (SELECT Count(*) FROM Customers C WHERE
C.CustomerID<=Customers.CustomerID) Mod 2=0;
===qselOdd==================
SELECT
(SELECT Count(*)
FROM Customers C
WHERE C.CustomerID<=Customers.CustomerID) Mod 2 AS OddEven,
(SELECT Count(*)
FROM Customers C
WHERE C.CustomerID<Customers.CustomerID)\2 AS Pair,
Customers.*
FROM Customers
WHERE (SELECT Count(*) FROM Customers C WHERE
C.CustomerID<=Customers.CustomerID) Mod 2=1;
Combine these two in a select query joining the "Pair" field. I used a RIGHT
JOIN since there may be more odd records than even records.
SELECT qselOdd.OddEven AS Odd, qselEven.OddEven AS Even, qselOdd.CompanyName
AS OddCompany, qselOdd.CustomerID AS OddID, qselEven.CompanyName AS
EvenCompany, qselEven.CustomerID AS EvenID
FROM qselEven RIGHT JOIN qselOdd ON qselEven.Pair = qselOdd.Pair;
BTW: Can I put this on my timesheet?