× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Is this what you want?

SELECT case when ANOUNT < 0 then AMOUNT else 0 end as credit,
case when AMOUNT >= 0 then AMOUNT else 0 end as debit,
AMOUNT
FROM GeneralLedger

Returns

CREDIT DEBIT AMOUNT
.00 308.00 308.00
55.77- .00 55.77-


John Arnold
(301) 354-2939

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of James Rich
Sent: Tuesday, February 17, 2009 5:16 PM
To: midrange-l
Subject: SQL clause to check value

I have a rather tricky problem that I think could best be solved with an

appropriate SQL statement. In my general ledger transaction file I have
a
field for the amount. What I really want are two fields: one for
debits
and one for credits. While I can't redesign the file, if I could create

two fields whose contents depend on the value of this one amount field
then I would be all set. If the amount field contains zero or a
positive
number I want to have a new debit field that contains the amount and a
new
credit field that contains zero. If the amount field is negative then
just the opposite should happen. Everything I've tried so far results
in
boolean results, not actually giving me two fields.

To be clear, suppose my amount field contains these two values:

AMOUNT
record 1: 100.00
record 2: -100.00

Then I want to run some SQL statement that will give me the following
results:

DEBIT CREDIT
record 1: 100.00 0.00
record 2: 0.00 -100.00

Make sense? Is that possible?

James Rich

if you want to understand why that is, there are many good books on
the design of operating systems. please pass them along to redmond
when you're done reading them :)
- Paul Davis on ardour-dev

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.