Selecting X number of records out of Y

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.
aftab2003Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Lee W, MVPTechnology and Business Process AdvisorCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
david_barkerCommented:
For the percentages :
    SELECT TOP 20 PERCENT * FROM Table
or SELECT TOP 50 PERCENT * FROM Table
0
jkwassonCommented:
you can also do this...

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

would return the first 50 records from tablea

jk
0
leonstrykerCommented:
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.