Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Help with SQL-statement !

Help with SQL-statement !

From: Ole Hansen <ohahaahr_at_hotmail.com>
Date: 14 Mar 2005 08:44:37 -0800
Message-ID: <3d05b5c1.0503140844.6c287453@posting.google.com>


Hi everybody !

I am an SQL-Newbie, who could need some help.

I have a table, "Stocktrans", with the following fields:

DATE QTY
---------- ------

01-01-2000     20
01-01-2000      4
01-01-2000     -5
01-01-2000     -2
10-02-2000     -3
20-03-2000      3
20-03-2000     -1
20-03-2000     -4

QTY>0 means inflow to my stock, and QTY<0 means OUTFLOW of my stock. I now want to make a script with 4 columns.

Column 1: Date
Column 2: Sum of stock INFLOW on that date
Column 3: Sum of stock OUTFLOW on that date
Column 4: Stocklevel at the end of the day.


The output should look like this:

DATE INFLOW OUTFLOW STOCKLEVEL
---------- ------ ------- ----------

01-01-2000     24       7         17 
10-02-2000              3         14
20-03-2000      3       5         12

Hopefully someone can help me.

Regards,
Ole Received on Mon Mar 14 2005 - 10:44:37 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US