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

Multiple Addresses, Need Only One per Person

Status
Not open for further replies.

bigdavidt

Programmer
Feb 12, 2004
52
US
I am working on a query for a mailing to a list of health care providers. (There can be several entries in the source table for the same provider, since each provider can work at more than one location.) However, we do not want to send more than one piece of mail to each provider. How do I pull only one record for each provider? (It is not important which mailing address gets used, just as long as only one address is extracted for each provider.)

Thank you in advance.
 
Perhaps something like:

[tt]Select ID, SName, FName,
(Select Top 1 Address
From tblTable A
Where A.ID=tblTableID)
From tblTable[/tt]

Assuming that the names and addresses are both in tblTable.
 
. . . or perhaps this:

[tt]Note: [purple]PK[/purple] = PrimaryKeyName
[purple]PN[/purple] = ProviderFieldName
[purple]TN[/purple] = TableName[/tt]
Code:
[blue]SELECT [purple][b]PK[/b][/purple], [purple][b]PN[/b][/purple], OtherFieldName, OtherFieldName
FROM [purple][b]TN[/b][/purple]
WHERE ((([[purple][b]PK[/b][/purple]]) In (SELECT Max([[purple][b]PK[/b][/purple]]) FROM [[purple][b]TN[/b][/purple]] GROUP BY [[purple][b]PN[/b][/purple]])));[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top