Vlook up in sql

  • Hi,

    I want to perform vlookup kind of operation in sql query

    I have a table with column A,B,C,D,Flag

    A B C D Flag

    1 1 a b NonMatch

    1 1 b a NonMatch

    1 1 c a NonMatch

    1 1 a c NonMatch

    These records are matching on the basis of A & B but diognaly and they should be match as per the requirement.Could you please help me making it as a match.

  • amittheming

    To help others to assist you, please, please post the table definition, sample data in an easily usable format, and most importantly the desired results from the sample data.

    To do this quickly and easily please click on the first link in my signature block and read how to do this.

    For others who may read this posting, and are not that familiar with Excel, the operation of the VLOOKUP function may be found at:

    http://office.microsoft.com/en-us/excel-help/how-to-look-up-a-value-in-a-list-and-return-multiple-corresponding-values-HA001226038.aspx

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Heh... I defy anyone to actually create a forumula with a single VLOOKUP in a single column in a spreadsheet to actually get this working. 😉 Don't even think of VLOOKUP when trying to solve this problem. 😉

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • amittheming (3/5/2011)


    Hi,

    I want to perform vlookup kind of operation in sql query

    I have a table with column A,B,C,D,Flag

    A B C D Flag

    1 1 a b NonMatch

    1 1 b a NonMatch

    1 1 c a NonMatch

    1 1 a c NonMatch

    These records are matching on the basis of A & B but diognaly and they should be match as per the requirement.Could you please help me making it as a match.

    What is the relationship between the columns? Are A&B interchangable or not? I see that C&D are interchangeable with each other but are they interchangeable with either A or B?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply