dbTalk Databases Forums  

Top Percent calculation in SQL wrong?

comp.databases.ms-access comp.databases.ms-access


Discuss Top Percent calculation in SQL wrong? in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
septimus
 
Posts: n/a

Default Top Percent calculation in SQL wrong? - 07-21-2011 , 10:18 AM






I have a query with (at present) 223 records, sorted from highest
percentage to lowest percentage.
I would like to create two more queries. One would contain the top 27%
from the first query and the other would contain the bottom 27%.

Access SQL would seem to make this easy. I just start my "top" and
"bottom" queries with the clause "SELECT TOP 27 PERCENT".

But that should give me 60 records in both the Top and Bottom queries,
right? Instead, I get 74 records in the top 27% query and 69 in the
bottom 27% query.

Anybody know why this is? Anything I can do differently to get the
results I'm looking for?

Thanks!

Reply With Quote
  #2  
Old   
Bob Barrows
 
Posts: n/a

Default Re: Top Percent calculation in SQL wrong? - 07-21-2011 , 10:56 AM






septimus wrote:
Quote:
I have a query with (at present) 223 records, sorted from highest
percentage to lowest percentage.
I would like to create two more queries. One would contain the top 27%
from the first query and the other would contain the bottom 27%.

Access SQL would seem to make this easy. I just start my "top" and
"bottom" queries with the clause "SELECT TOP 27 PERCENT".

But that should give me 60 records in both the Top and Bottom queries,
right? Instead, I get 74 records in the top 27% query and 69 in the
bottom 27% query.

Anybody know why this is? Anything I can do differently to get the
results I'm looking for?

Thanks!
There's probably some ties. You need to break the ties by adding as many
fields are needed to the ORDER BY clause.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.