Hi,
Here's my problem....I have an "employee" table and an "activity" table and an "ActivityEmployeeDetail" table.
one activity can have multiple employees and the details of that activity are stored in the "ActivityEmployeeDetail" one record for each employee
Activity table
ActivityID Date
1 1/1/2010
2 2/2/2010
3 3/3/2010
Employee Table
EmployeeID EmpLastName
45 smith
88 green
99 Johnes
33 lopex
22 Person
ActivityEmployeeDetail table
AcitityDetailID ActivityID EmployeeID detail
1 1 45 blah blah
2 1 88 stuff
3 2 99 blah blah
4 3 33 blah blah
5 3 22 blah blah
I have this big query that returns the following results
ActivityID EmployeeID EmpLastName Date
1 45 Smith 1/1/2010
1 88 Greem 1/1/2010
2 99 Johnes 2/2/2010
3 33 Lopex 3/3/2010
3 22 Person 3/3/2010
I would like the query to return a result that show only the 1st record found of each activiy.
ActivityId EmployeeID EmpLastName date
1 45 smith 1/1/2010
2 99 johnes 2/2/2010
3 33 Lopex 3/3/2010
in this example even though ActivityIds 1 and 3 have 2 records each the query would only return the 1st
or can I concat the employeeID and EmpLastName fields to return records like this
ActivityID EmployeeID EmpLastName Date
1 45,88 smith,green 1/1/2010
2 99 johnes 2/2/2010
3 33,22 Lopex,Person 3/3/2010
my original query looks like this
Select a.activityID,ae.employeeID,e.LastName,a.date
from Activity a
inner join activityEmployee ae on a.activityid = ae.activityid
inner join employee e on ae.employeeID = e.employeeID
order by a.date
thanks for your help
joe
Here's my problem....I have an "employee" table and an "activity" table and an "ActivityEmployeeDetail" table.
one activity can have multiple employees and the details of that activity are stored in the "ActivityEmployeeDetail" one record for each employee
Activity table
ActivityID Date
1 1/1/2010
2 2/2/2010
3 3/3/2010
Employee Table
EmployeeID EmpLastName
45 smith
88 green
99 Johnes
33 lopex
22 Person
ActivityEmployeeDetail table
AcitityDetailID ActivityID EmployeeID detail
1 1 45 blah blah
2 1 88 stuff
3 2 99 blah blah
4 3 33 blah blah
5 3 22 blah blah
I have this big query that returns the following results
ActivityID EmployeeID EmpLastName Date
1 45 Smith 1/1/2010
1 88 Greem 1/1/2010
2 99 Johnes 2/2/2010
3 33 Lopex 3/3/2010
3 22 Person 3/3/2010
I would like the query to return a result that show only the 1st record found of each activiy.
ActivityId EmployeeID EmpLastName date
1 45 smith 1/1/2010
2 99 johnes 2/2/2010
3 33 Lopex 3/3/2010
in this example even though ActivityIds 1 and 3 have 2 records each the query would only return the 1st
or can I concat the employeeID and EmpLastName fields to return records like this
ActivityID EmployeeID EmpLastName Date
1 45,88 smith,green 1/1/2010
2 99 johnes 2/2/2010
3 33,22 Lopex,Person 3/3/2010
my original query looks like this
Select a.activityID,ae.employeeID,e.LastName,a.date
from Activity a
inner join activityEmployee ae on a.activityid = ae.activityid
inner join employee e on ae.employeeID = e.employeeID
order by a.date
thanks for your help
joe