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.
| Author |
Topic |
|
jonboy
Starting Member
2 Posts |
Posted - 2002-01-09 : 05:46:56
|
| Hi there,I have a small problem which I need a few hints on.I am trying to pull out data from a database and modify some of it based on an identifier on the way.eginvoicenumber quantity total invoicetype12312 100 £792 112323 50 £45 317263 5 £86 218256 10 £10 3With this example data I need to pull out all the values but where the invoice type is 3 I need the quantity and totals to have a minus put in front of them.I have tried several ideas but my mind is now stuck in a rut!!!Any ideas! |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2002-01-09 : 05:54:19
|
Hi JonboyYou can do this with the [url="http://www.sqlteam.com/item.asp?ItemID=922"]CASE{/url] statement.Something like this :SELECT invoicenumber, quantity, CASE WHEN invoicetype=3 THEN 0 - quantity ELSE quantity END as total, invoicetypeFROMmytable How is that ?Damian |
 |
|
|
jonboy
Starting Member
2 Posts |
Posted - 2002-01-09 : 11:34:35
|
| Thanks a lot Merkin, that shot the bitch out of the sky quicksmart! |
 |
|
|
|
|
|