set condition via flag column

  • Hi,

    I have a source table below:

    organization interco account curr amount organization interco account curr amount

    3050000 2650000 2331200D USD 315.00 2650000 3050000 4132000D USD -15.00

    3050000 3051000 2331200D USD -58421.43 3051000 3050000 4132000D USD -1115.16

    3050000 3051000 2331200D USD -58421.43 3051000 3050000 4163100D USD -352000.00

    3050000 3051000 2331200D USD -58421.43 3051000 3050000 4163200D USD -10.31

    Below is my interco_flag table. It determines which account to match by the flag values to filter the records in source table.

    account flag

    2331100D 1

    2331200D 2

    4131000D 1

    4132000D 2

    Since the flag = 2 matches the account ID in the source table, the desired results will look like this:

    organization interco account curr amount organization interco account curr amount

    3050000 2650000 2331200D USD 315.00 2650000 3050000 4132000D USD -15.00

    3050000 3051000 2331200D USD -58421.43 3051000 3050000 4132000D USD -1115.16

    How can I construct the sql in order to match the account ID flag in the source table?

  • select t1.*

    from t1 inner join t2 on (t1.column = t2.column)

    where t2.condition_column = condition_value

    You have to replace values, table names and column names to match your scenario.



    Ole Kristian Velstadbråten Bangås - Virinco - Facebook - Twitter

    Concatenating Row Values in Transact-SQL[/url]

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

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