Client id which are link to any trading code

  • [font="Courier New"]

    Dear All

    I have a problem, I have data like this

    ID Product Product_code Status

    19 EAI ZBC82 Active

    19 EAI Z23V7Inactive

    16 DP 13598940Active

    Now I want to select record in this format for check whether all such DP Product code id have any Active trading code in same id.

    Client ID Trading_Code Status

    13598940 ZBC82 Active

    [/font]

  • in general, you'll see two ways to do this.

    you can use a

    SELECT * FROM TABLE1 WHERE [Client ID] in (SELECT [Client ID] FROM TABLE2 WHERE Trading_Code IN('ZBwhatever') )

    or you can left outer join the table

    SELECT * FROM TABLE1

    LEFT OUTER JOIN TABLE2 ON TABLE1.[Client ID]=TABLE1.[Client ID]

    WHERE WHERE TABLE2 .Trading_Code IN('ZBwhatever')

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Viewing 2 posts - 1 through 1 (of 1 total)

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