Prev: QueryNext: Sequence From: Tyro on 8 Mar 2010 16:11 How can I get the "Amount" to be a negative number when the "Code" = "G6"? Maybe I could multiply by -1 and use the CASE statement, but I don't know how. Table Name = EncounterData Amount Code \$15.00 G2 \$13.00 G2 \$18.00 G6 \$16.00 G2 \$25.00 G6 \$30.00 G6 -- Tyro from Missouri From: Tom Cooper on 8 Mar 2010 16:21 You're right, use a CASE, for example Select Case When Code = 'G6' Then -1 * Amount Else Amount End As Amount, Code From EncounterData; Tom "Tyro" wrote in message news:20959474-72BF-454D-8820-0AC2F90BA7F6(a)microsoft.com...> How can I get the "Amount" to be a negative number when the "Code" = "G6"? > Maybe I could multiply by -1 and use the CASE statement, but I don't know > how. > > Table Name = EncounterData > > Amount Code > \$15.00 G2 > \$13.00 G2 > \$18.00 G6 > \$16.00 G2 > \$25.00 G6 > \$30.00 G6 > > -- > Tyro from Missouri From: RJ Roberts on 8 Mar 2010 16:34 The case statement will work nicely for this. Obviously I don't know your data but watch out for an Amount already being negative. Select Amount = Case When Code = 'G6' then ABS(Amount)*-1 Else Amount End, Code from ... -- RJ Roberts DB Architect/Developer "Tyro" wrote: > How can I get the "Amount" to be a negative number when the "Code" = "G6"? > Maybe I could multiply by -1 and use the CASE statement, but I don't know how. > > Table Name = EncounterData > > Amount Code > \$15.00 G2 > \$13.00 G2 > \$18.00 G6 > \$16.00 G2 > \$25.00 G6 > \$30.00 G6 > > -- > Tyro from Missouri From: Tyro on 8 Mar 2010 16:45 Thank you RJ. -- Tyro from Missouri "RJ Roberts" wrote: > The case statement will work nicely for this. Obviously I don't know your > data but watch out for an Amount already being negative. > > Select Amount = Case When Code = 'G6' then ABS(Amount)*-1 Else Amount End, > Code from ... > > -- > RJ Roberts > DB Architect/Developer > > > "Tyro" wrote: > > > How can I get the "Amount" to be a negative number when the "Code" = "G6"? > > Maybe I could multiply by -1 and use the CASE statement, but I don't know how. > > > > Table Name = EncounterData > > > > Amount Code > > \$15.00 G2 > > \$13.00 G2 > > \$18.00 G6 > > \$16.00 G2 > > \$25.00 G6 > > \$30.00 G6 > > > > -- > > Tyro from Missouri From: Michael C on 8 Mar 2010 19:54 "RJ Roberts" wrote in message news:BB76D584-D8D4-43D4-A537-> Select Amount = Case When Code = 'G6' then ABS(Amount)*-1 Else Amount End, > Code from ... Instead of multiply by -1, can't we just do -ABS(Amount) or -Amount? I don't think the ABS is required. Michael  |  Next  |  Last Pages: 1 2 Prev: QueryNext: Sequence