Return unique record

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a contacts tbl and a donor table with a one to many relationship.
I am trying to select all contacts that have ever given and only return
their phone number. I am retuning multiple data for every contact for every
gift.
for example:
Joe gave 20 times and I am returning
joe phone number gift_number 1
joe phone number gift_number 2
ect.
How do i limit the results to meet the criteria that they have given and
return their phone number?


here is the SQL
SELECT Contacts.NewSwadleyID, tblSupportRecord.GiftDate, Contacts.WorkPhone
FROM Contacts INNER JOIN tblSupportRecord ON Contacts.NewSwadleyID =
tblSupportRecord.NewSwadleyID
GROUP BY Contacts.NewSwadleyID, tblSupportRecord.GiftDate, Contacts.WorkPhone
ORDER BY Contacts.NewSwadleyID, tblSupportRecord.GiftDate DESC;
 
SELECT DISTINCT Contacts.NewSwadleyID,
Contacts.WorkPhone
FROM Contacts INNER JOIN tblSupportRecord
ON Contacts.NewSwadleyID = tblSupportRecord.NewSwadleyID
ORDER BY Contacts.NewSwadleyID ;

or

SELECT Contacts.NewSwadleyID,
Contacts.WorkPhone,
Max(tblSupportRecord.GiftDate)
FROM Contacts INNER JOIN tblSupportRecord
ON Contacts.NewSwadleyID = tblSupportRecord.NewSwadleyID
GROUP BY Contacts.NewSwadleyID,
Contacts.WorkPhone
ORDER BY Contacts.NewSwadleyID DESC;
 
I will give her a go,
Thanks so so much, I have been trying to figure this one out for a while!
 
Back
Top