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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Uniq Records question

Status
Not open for further replies.

Hokis

Technical User
May 21, 2007
51
US
I have this table that has codes in it like FF & AA & BB.
All i need to do is get the uniq record for each, I mean index on the uniq record & export it as a table. How can i do that.
Thanks
 
Do you mean unique field or unique record?

If it is just a field then
Code:
Select DISTINCT SomeField From SomeTable

If it is unique records then every record in a table should be unique.
 
what i mean is i have a table with name address city st & zip & code field, which couple of the rows have the same codes, like AA, then another rows have different codes like BB, so I need to pull out one name per code (like grab the hole row), but index it on code, so I'll have one name (with address)with AA code & one name (with addresses)with BB code.
can it be done.
Like in Fox Pro u do.
Index on code to s1 uniq
That indexes on code field & give my every uniq record (with the hole row).
Pls Help.Thanks
 
Please, post some input sample, what you've tried so far (SQL code) with result vs expected output.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
ok here is my table
ACCOUNT FIRST LAST COMPANY code
88888 ABY LastName ABC AAA
88888 ABY LastName ABC AAA
88888 ABY LastName ABC BBB
88888 ABY LastName ABC BBB
88888 ABY LastName ABC CCC
88888 ABY LastName ABC DDD
88888 ABY LastName ABC CCC
88888 ABY LastName ABC BBB
88888 ABY LastName ABC DDD
88888 ABY LastName ABC AAA

Of course it's much bigger then couple of records.
I want to make a query to get the uniq Codes & give me the hole row.
Like AAA code with First-last... etc. whatever row i have according to the code.
But i want one of each code, or maybe 2 of each code.
How can i do it.
with distinct it gives me only the code not the hole row.
PLEASE HELP. thank you
 
Hi Hokis,
One of each code of two of each code is very different. However, here's one of each code based on your information above:

SELECT ACCOUNT, FIRST, LAST, COMPANY, code
FROM MyTable
GROUP BY ACCOUNT, FIRST, LAST, COMPANY,code;

where MyTable represents the name of your table.

Hope this helps.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top