Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations dencom on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Index

Status
Not open for further replies.

Hokis

Technical User
May 21, 2007
51
US
Hi, i have this table that has a field that has 3 different names in it Like AAA-BBB & CCC but i have 1000 records they all are repeated. What i need to do is in the query i need to select AAA but only 3 records (random) of it, i don't want 500 AAAs, i just need 3 records.
I know how to put in the criteria "AAA" but it's bringing me the whole AAAs, so any suggestions???
OR maybe my question is not clear enough I need to index on a specific field, but get 3 of each that indexed records.
Thanks
Hokis
 

If you use the Search above with random records there are 54 posts, many of them with stars! Please try those out first, then let us know if you need any help beyond that.
 
actually i couldn't find anything, what i want is Not exactly a random number, i want it to index on a specific field & bring me 3 of each selection.
Like if i have a field has AAA, BBB, & DDD
I want it to bring me 3 AAA, 3 BBB & 3 DDDs
is that possible & how
Thanks
Alice
 
How about SELECT TOP 3...?
Won't be random, but at least will only return 3 records...

All I ask is a chance to prove that money can't make me happy.
 

The 3rd post of those is thread701-1428273 where pwise has the answer. Would you try it?
 
Hi genomon, I tried that select top 3, which is fine except when i'm indexing on the field itseld it's giving me only 3 records instead of 3 of each.
like i want AAA (3 records), BBB (3 records) & CCC (3 Records).
so in that field criteria i'm puting in one line aaa & in the second line bbb & in the 3rd line ccc, but when i'm doing select top 3 thing, it's only selecting the top 3 that is in the list not indexing on the record & selecting top 3 of each.
Hope i was clear in my explanation, & someone can help me.
Thanks again
Hokis
 
Could you please provide some sample data (including field names) and your expected results....

Leslie

In an open world there's no need for windows and gates
 
provide some sample data (including field names) and your expected results
And your actual SQL code too.
 
First Last Group
Bill F AAA
Al S BBB
John D AAA
John G CCC
Rita D BBB
Mark F BBB

What I need is to index on field 'Group" to find the uniq codes that r available there & then get 3 of each those codes.so in this case the query should find 3 uniq codes AAA, BBB & CCC, & it should pick 3 of each those codes.
IS that clear, or not yet??? pls let me know & thank you
Hokis
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top