• malcolm.garbett (11/3/2012)


    Thanks guys, but...

    Let me try and be more clear.

    The data is coming from a table where the monetary value is always "just" a value so the output looks like:

    Example:

    Columns.

    Inv/Credit Amount

    SI-100 10.00

    SI-200 12.75

    SI- 300 250.00

    SC-100 18.50

    Where in the Inv/Credit column the id is prefixed with a "SC" I know that's a credit note so in this report - written in BIRT - for the accounts guys, I need to leave the "SI" values "as is" but have a minus symbol where there is a "SC" so it outputs like this:

    Columns.

    Inv/Credit Amount

    SI-100 10.00

    SI-200 12.75

    SI- 300 250.00

    SC-100 -18.50

    You may have to change the column names and, certainly, the table name, but the following will do it quite nicely.

    SELECT [Inv/Credit],

    Amount = CASE WHEN LIKE 'SC%' THEN Amount ELSE -Amount END

    FROM dbo.YourTable

    ;

    --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)