?
Solved

Selecting X number of records out of Y

Posted on 2005-03-26
5
Medium Priority
?
242 Views
Last Modified: 2013-12-25
Hi,

I want to select X number of records out of Y number of records.
How do i do that ?

i.e. suppose I have 100 records(Y)
I want to select 50 records(X)  out of these 100 records
How do I do that ? And if I want to select 50% (or 20%), how do I do that ?

Is it different in DAO/ADO ?

select X...? I have no clue

Thanks.
0
Comment
Question by:aftab2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 96

Accepted Solution

by:
Lee W, MVP earned 400 total points
ID: 13635347
Depends on the database you're using, but typically in MS SQL and Access, it would be "SELECT TOP x * FROM Table"

But I'm not sure if that would work with %'s.  It definitely works for a specific number of records, like if you wanted the top 3 records, you'd say SELECT TOP 3 * FROM Table
0
 
LVL 6

Expert Comment

by:david_barker
ID: 13636341
For the percentages :
    SELECT TOP 20 PERCENT * FROM Table
or SELECT TOP 50 PERCENT * FROM Table
0
 
LVL 5

Expert Comment

by:jkwasson
ID: 13638621
you can also do this...

select count(*) as recordcount from tablea where recordcount = 50

would return the first 50 records from tablea

jk
0
 
LVL 29

Expert Comment

by:leonstryker
ID: 14012921
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:

Answered leew (13635347)

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

leonstryker
EE Cleanup Volunteer
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question