Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
rotero
Creator
Creator

sql case statement during edit script loading

hi i have a SQL table as my souce data and i want to effect this change in data representation

date field are

TRCD  - numeric date referrring to transaction code (1=invoice and 3 =returns)

AMT - amt (no negative value)

what i want to achieve is when trcd=3 amt will represent data in negative status so that when i sum(amt) it will give me net sale

ex.

trcd=1

amt= 1000

trcd=3

amt=(1000)

1 Solution

Accepted Solutions
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Try this way.

    Load

    trcd,

    if(trcd = 3, amt * -1,amt) as new_amt;

    Sql Select trcd, amt

    from xyz

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!

View solution in original post

1 Reply
kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

    Try this way.

    Load

    trcd,

    if(trcd = 3, amt * -1,amt) as new_amt;

    Sql Select trcd, amt

    from xyz

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!