Re: SqlPlus question

From: Andreas Koester <AKoester_at_DerPatriot.com>
Date: Tue, 08 Jun 1999 10:37:23 +0200
Message-ID: <375CD643.AC990A25_at_DerPatriot.com>


[Quoted] Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit

Hi Sham,

you already did a

compute sum of debit on report
compute sum of credit on report
break on report skip 1

select account, debit, credit
from xyz
order by account;

clear breaks
clear computes

or something like that.

If what you want is a list looking like this

Account Debit Credit Diff
-------- ------ ------- -----
a/c1 25 45 20

you have to

select account, sum(debit) debit, sum(credit) credit , sum(credit)-sum(debit) diff
from xyz
group by account
having sum(credit)-sum(debit) != 0;

Bye,

Andreas Koester
Akoester_at_DerPatriot.com

Sham wrote:

> Hi, I'm looking for a means to solve the following problem in sqlplus :
> I have the following columns :
>
> Account       Debit       Credit
> =====        ====       ====
> a/c1             10               20
> a/c1             15              25
> Sum             25               45        <- Line calculated in a break ...
> compute statement
>
> Now, I want to calculate the difference between the sum of debit and the sum
> of credit and display it underneath. The finality of that is to find an
> account where sum(debit) is different from sum(credit)
>
> How can I do that ? Thanks for helping me.
> Please also reply to shameemg_at_club-internet.fr

--------------0C20308CFF230AB1435C04E8

Content-Type: text/html; charset=us-ascii Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hi Sham,
<p>you already did a
<p>compute sum of debit on report
<br>compute sum of credit on report
<br>break on report skip 1
<p>select account, debit, credit
<br>from xyz
<br>order by account;
<p>clear breaks
<br>clear computes
<p>or something like that.
<p>If what you want is a list looking like this
<p>Account&nbsp; Debit&nbsp;&nbsp; Credit&nbsp;&nbsp;&nbsp; Diff
<br>--------&nbsp; ------&nbsp; -------&nbsp;&nbsp; -----
<br>a/c1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
45&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20
<p>you have to
<p>select account, sum(debit) debit, sum(credit) credit , sum(credit)-sum(debit)
diff
<br>from xyz
<br>group by account
<br>having sum(credit)-sum(debit) != 0;
<p>Bye,
<p>Andreas Koester
<br><a href="mailto:AKoester_at_DerPatriot.com">Akoester_at_DerPatriot.com</a>
<p>Sham wrote:
<blockquote TYPE=CITE>Hi, I'm looking for a means to solve the following
problem in sqlplus :
<br>I have the following columns :
<p>Account&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Debit&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Credit
<br>=====&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ====&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;



<br>a/c1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
10&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 20
<br>a/c1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
15&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 25
<br>Sum&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
25&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 45&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;- Line calculated in a break ...
<br>compute statement
<p>Now, I want to calculate the difference between the sum of debit and
the sum
<br>of credit and display it underneath. The finality of that is to find
an
<br>account where sum(debit) is different from sum(credit)
<p>How can I do that ? Thanks for helping me.
<br>Please also reply to shameemg_at_club-internet.fr</blockquote>
</html>

--------------0C20308CFF230AB1435C04E8-- Received on Tue Jun 08 1999 - 10:37:23 CEST

Original text of this message