Is there a way to combine these IN statements?

  • I am trying to determine if one or the other value exists in a subquery result set. For some reason I'm drawing a blank at being able to combine this

    SELECT [ColA] = CASE

    WHEN ('Multiple Suppliers' IN (

    SELECT CompanyName

    FROM tlkLookUp

    WHERE [WP] = '40' )

    OR

    Col_CompanyName IN (

    SELECT CompanyName

    FROM tlkWorkPackages_CompanyNames

    WHERE [WP] = '40' )

    )

    Then Do something...

  • Hi

    Can't try because there are not test data 😉

    Try this:

    SELECT

    [ColA] = CASE

    WHEN EXISTS (

    SELECT TOP(1) 1

    FROM tlkLookUp

    WHERE WP = 40

    AND CompanyName = 'MultipleS Suppliers')

    OR EXISTS (

    SELECT TOP(1) 1

    FROM tlkWorkPagackes

    WHERE WP = 40

    AND CompanyName = ExtAlias.Col_CompanyName)

    THEN 1

    ELSE 0

    END

    FROM bla extalias

    Greets

    Flo

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

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