Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2012
    Posts
    8

    Unanswered: Multi-value Column

    Hello all,

    I am trying to exclude records from a table where the ID column is the same but the Mail code Column is multi-valued.

    For Example: (the table looks like....)

    ID Mail_code
    111111 XNT
    111111 N11
    111111 XNC
    222222 XNC
    222222 XNL
    333333 XNC

    So, if there is any ID that has a value of XNC, I want to exclude the ID all together from my output regardless of the other values.


    Please help....thank You.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Code:
    with badrecords
    as
    (select distinct ID
    from tablename
    where mail_code = 'XNC'
    )
    
    select *
    from table
    where ID not in (select ID from badrecords)

  3. #3
    Join Date
    Nov 2012
    Posts
    8
    Thanks for your quick response. However, that did not work for me. I am using Microsoft SQL server Management Studio.

    I also tried....which is still returning too many records.

    select a.id, A.PERSON_MULTIPLE_SOURCES
    from dbo.ODS_PERSON_SOURCES A
    WHERE EXISTS
    (SELECT B.ID
    FROM dbo.ODS_PERSON_MAIL_RULES B
    WHERE ((MAIL_RULES != 'XNC' OR MAIL_RULES IS NULL)))
    and PERSON_MULTIPLE_SOURCES IN ('ADA','AEA')

  4. #4
    Join Date
    Nov 2012
    Posts
    8
    MCrowley, Thank you so much for your help.

    The code you sent me DID work. Thank you.

    ArtnetteS

Posting Permissions

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