Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL View

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2010-03-24 : 15:57:38


Table: iminvtrx_sql

select source, item_no, loc, doc_dt, doc_type, quantity
from iminvtrx_sql

How can I modify this statement to multiply "quantity" by -1 if source = 'O' and doc_type = 'R'

Or do I have to create a new field????

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-03-24 : 16:07:41
select
source,
item_no,
loc,
doc_dt,
doc_type,
case when source = 'O' and doc_type = 'R' then quantity * -1 else quantity end as quantity
from iminvtrx_sql


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -