That would be quite complicated. I know you can do a "SELECT TOP 50 PERCENT ... " for your main query, and that will return the first half of the records. The second half would have to be done using an inner SELECT statement that selects the TOP 50 PERCENT, but the order is reverse (essentially, grab the last 50 percent). The outer SELECT statement would then reverse the order so that it comes out the same. End result: two separate result sets each containing approximately half of the records. So then the problem becomes: how do I get it into a single resultset so that ListX can handle it nicely.
Here are the steps you'll have to do in your main query:
1) Create a temporary table with an identity column (say, RowNumber) and has 2 columns for every column you want displayed. For example, if you're doing a side-by-side listing of the Tabs in your system, then create a temp table with fields: TabID1, TabName1, TabID2, TabName2.
2) Insert into the fields ending with 1 using the statement "SELECT TOP 50 PERCENT ...".
3) Insert into the fields ending with 2 using the reversal statement "SELECT * FROM (SELECT TOP 50 PERCENT FROM... ORDER BY ...)"
4) Update the fields in the first half of the records with data from the second half.
5) Delete the second half of the records.
In your formatting, use the fields TabID1 and TabID2 to show the tab ids side-by-side. The complete SQL is below.
DECLARE @HalfCount int /* This is used for marking the first half of the records */
CREATE TABLE #tmpTabs
(
RowNumber [int] IDENTITY(1,1) NOT NULL,
TabID1 [int],
TabName1 [nvarchar](250),
TabOrder1 [int],
TabID2 [int],
TabName2 [nvarchar](250),
TabOrder2 [int]
)
INSERT INTO #tmpTabs (TabID1, TabName1, TabOrder1)
SELECT TOP 50 PERCENT TabID, TabName, TabOrder
FROM Tabs
ORDER BY TabOrder ASC
SELECT @HalfCount = SCOPE_IDENTITY() /* Retains RowNumber for last record written */
INSERT INTO #tmpTabs (TabID2, TabName2, TabOrder2)
SELECT *
FROM ( /* This is the inner reversed statement */
SELECT TOP 50 PERCENT TabID, TabName, TabOrder
FROM Tabs
ORDER BY TabOrder DESC) ReverseTabs
ORDER BY TabOrder ASC
/* Update the first half of the records with data from the second half */
UPDATE #tmpTabs SET
TabID2 = Half.TabID2,
TabName2 = Half.TabName2,
TabOrder2 = Half.TabOrder2
FROM #tmpTabs INNER JOIN (SELECT (RowNumber - @HalfCount) AS RowNumber, TabID2, TabName2, TabOrder2 FROM #tmpTabs) Half
ON #tmpTabs.RowNumber = Half.RowNumber
/* Remove the extraneous half */
DELETE FROM #tmpTabs WHERE RowNumber > @HalfCount
SELECT * FROM #tmpTabs ORDER BY TabOrder1, TabOrder2
Your format is then simply:
<tr><td>[TabName1]</td><td> | </td><td>[TabName2]</td></tr>