Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100

    Unanswered: DISTINCT First Name and Last Name for Mail Merge

    I'm trying to create a mail merge on my MS SQL database. Many of my owners are entered more than once as they might own multiple properties. I'm trying to write a query where each is only pulled one time and I'm having some trouble. I think I need to use SELECT DISTINCT, but I need to make sure I don't filter out people with the same first name and different last names and vice versa. Thanks!
    BillS

  2. #2
    Join Date
    Oct 2004
    Posts
    91

    Soundex

    One of my old bosses insisted this could be done using soundex

    don't know, but maybe that is an area to start?

    http://www.4guysfromrolla.com/webtec...103101-1.shtml




    good luck

  3. #3
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100
    It doesn't need to be that deep.

    I thought of another idea. How do I use SELECT DISTINCT to return all rows in my table and only unique address fields?
    BillS

  4. #4
    Join Date
    Oct 2004
    Posts
    91

    Grouping

    I think that a group statement might accomplish this??

    as in

    select f_name from table group by f_name

    I re-read your post...

    address validation is a trick....

    the address field can be set up many ways, and the street
    type designation can also be setup in a whole slew
    of different ways...

    what does your address field look like (sample data)


    thanks
    tony
    Last edited by alt-088; 12-01-05 at 16:24.

  5. #5
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Soundex is a practically useless algorithm.

    You can select distinct First/Last names in a subquery, but then which address would you use if the two records do not agree?

    Here is one of the simplest methods:
    Code:
    select	YourTable.*
    from	YourTable
    	inner join --DistinctNames
    		(select	Max(PrimaryKey) as PrimaryKey
    		from	YourTable
    		group by FirstName,
    			LastName) DistinctNames
    		on YourTable.PrimaryKey = DistinctNames.PrimaryKey
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  6. #6
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100
    You da' Blindman! Thanks, that's exactly what I needed.
    BillS

  7. #7
    Join Date
    Jun 2005
    Location
    Denver, CO
    Posts
    100
    I hate to post an extension to the question in the same place, but here goes. My owners are listed more than once if they own more than once parcel of land. What I need to do next is continue the merge to each only once, but add up their land acreage amounts and total for each person. Thoughts anyone? Thanks in advance.
    BillS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •