Selecting the top 1/3 of a table

A

ASP.Confused

I have a table with 306 records. If I select the top 33.333333333 percent,
it's returning 101 rows. It should return 102 rows.

Thinking that this was possibly a round-off error...I tried selecting the
top 99 percent, and it returned 303 rows. When 306 * 0.99 = 302.94, I'm now
not too sure it's truly a round-off error...because... 306 * 0.33333333333 =
101.99999, which if the row count were rounded up like the top 99 percent, it
should return 102.

Does anyone have any suggestions?
 
J

John Spencer

I'm guessing that Access is only accepting the number before the decimal
point for figuring out the percentage. 33 percent of 306 is 100.98 (101).

Is it a bug? Or is it not documented fully? I would have liked an error
message that says that complained about the number not being an integer, but
that doesn't seem to be the case.
 
A

ASP.Confused

Yeah...I had posted on another website this same question, and just about an
hour or two ago someone told me that it only accepts integer values for the
percentage...which pretty much leaves everyone out who wants 1/3, 1/7, 1/11,
1/13, 1/17, 1/19, etc. of the data.

An error message would have been nice...but then again...it still wouldn't
solve the problem I have...but just let me know sooner what was going on.

If only Microsoft implemented a row counter directly into the query language
(like Oracle's ROWCOUNT), that would make everyones life so much easier. Or
better yet, scrap Access altogether, and rebuild it on top of their light SQL
server. (and VB macros need to be stripped out of Office altogether, and
upgraded to .NET)

Well, now that I've had my little rant...lol...I thank you for attempting to
help me out. If you happen to know of anything that may help (and doesn't
use macros), please let me know. :)
 
J

Jerry Whittle

I was put in SELECT TOP 33.4 PERCENT and return 101 records when sorting on
the primary key.

When I typed in SELECT TOP 33.5 PERCENT the query returned 105 records.
Looks like it does round the percent.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top