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!

Finding unique values to associate to an individual

Status
Not open for further replies.

tjc240e

Technical User
Nov 12, 2004
133
US
I have a table of attendance.
basically it is like:
A B C
1 1 1/1/04
1 2 1/1/04
1 3 1/2/04
1 2 2/4/04
1 2 3/2/04
1 3 3/5/04
1 1 4/5/04
1 2 4/8/04
2 3 1/1/04
2 3 2/4/04
2 1 2/5/04
2 1 3/9/04
2 1 4/5/04
2 3 5/5/04

A is the person_ID
B is the event_ID
C is the event_date

I have table of Person and an event table
The person table contains just person_ID and Fullname
The event table contains just event_ID and eventname

i want to create a list of unique items so that person 1 will have a list of 1,2,3 and person 2 will have a list of 1,3

Right now i keep trying to get a list for them but it keeps giving me each one as if they are all unique

suggestions?
 
Ok that worked good... how about this
I have:
table1 containing Pers_code and Event_code
table2 containing Event_code, Event_date, Event_cat

what i would like to find is a unique instance of Event_cat per pers_code...

table1: table2:
pers_code event_code event_code event_date event_cat
1 2 2 08/10/97 16
1 15 15 07/20/97 16
1 1279 183 02/01/98 16
1 1282 458 10/24/99 16
2 183 992 05/28/02 25
2 458 1163 01/12/03 16
3 2 1279 06/16/03 24
3 1282 1282 08/03/03 21

So i need to return into a new table or query:
1 16
1 24
1 21
2 16
3 16
3 21

would this be done in a similar manner?
 
Here you go

SELECT tabl1.pers_code, tabl2.event_cat FROM table1 as tabl1, table2 as tabl2 WHERE tabl1.event_code = tabl2.event_code GROUP BY tabl2.event_cat, tabl1.pers_code ORDER BY tabl1.pers_code

It will be slow if you have a lot records in these tables.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top