Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to make query results positive or negative ?
Message
 
To
13/01/2000 04:58:43
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00317439
Message ID:
00317448
Views:
14
John,

I'll assume that your transaction table has the fields cTransactionType ("BUY" or "SELL") and yTransactionAmount.

Try
SELECT TYPE, ;
   TOTAL * iif(TYPE = "BUY", 1, -1) as TOTAL ;
 FROM Transaction ;
 yada, yada, yada ...
Cheers,

Andrew

>I do have a query like: SELECT TYPE, TOTAL from Transaction
>which results something like:
>TYPE TOTAL
>BUY 2000
>SELL 1000
>SELL 500
>
>However I would like to have the result like this
>BUY + 2000
>SELL - 1000
>SELL - 500
>
>So depending on the TYPE there will be a + / - before the TOTAL.
>How can I make that happen ?
>
>Thanks
>
>John
>
>PS: feel free to send suggestions to my private emailaddress


If we were to introduce Visual FoxBase+, would we be able to work from the dotNet Prompt?


From Top 22 Developer Responses to defects in Software
2. "It’s not a bug, it’s a feature."
1. "I thought I fixed that."


All my FoxTalk and other articles are available on my web site.


Unless specifically identified otherwise, anthing posted here is purely my opinion and may or may not reflect the policies or practices of Microsoft.
Previous
Reply
Map
View

Click here to load this message in the networking platform