Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Split table into thirds

Author  Topic 

lane0618
Posting Yak Master

134 Posts

Posted - 2003-06-25 : 11:23:39
How can a split a table into thirds?
Something following this logic:

select top(0%-33%) *
from awarddetails

select top(34%-66%) *
from awarddetails

select top(67%-100%) *
from awarddetails

Thanks!
Lane

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2003-06-25 : 12:00:03
More generally, you're asking about paging. There are lots of articles on SQLTeam that describe various techniques for it.

Jonathan
{0}
Go to Top of Page

lane0618
Posting Yak Master

134 Posts

Posted - 2003-06-25 : 13:02:24
I'm not trying to page through a recorset. I need to divide an entrire recordset up and display it in three differnt columns in an ASP page. Whats the best way to do this?

Thanks

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-06-25 : 13:15:32
quote:

I need to ... display it in three differnt columns in an ASP page. Whats the best way to do this?


The best way to do this in on the display layer (ASP).

If you can't, then do a search on paging and use the various techniques to return the three rowsets. I understand you are not 'paging' but the technique is applicable.

Jay White
{0}
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2003-06-25 : 17:10:55
I would use the getrows() method of an ado recordset to fill up an array.

set N = size of array = # of rows returned

N/3 = size of each column

then just do something like this in your asp page:

<TABLE>
<COL><COL><COL>
<TR>
<TD>
-- print the first n/3 elements of your array
</TD>
<TD>
-- print the next n/3 elements of your array
</TD>
<TD>
-- print final n/3 elements
</TD>
</TR>
</TABLE>

keep it simple ... don't return 3 recordsets or force SQL to do something it's not good at (i.e., paging). ASP is really good at doing this kind of stuff -- better than most report writing software, actually.

let me know if you have any problems or need more details...

- Jeff

Edited by - jsmith8858 on 06/25/2003 18:43:19
Go to Top of Page
   

- Advertisement -