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 -> Re: Help with SQL-statement !

Re: Help with SQL-statement !

From: Rene Nyffenegger <rene.nyffenegger_at_gmx.ch>
Date: 14 Mar 2005 19:10:36 GMT
Message-ID: <39m5tbF60kfigU1@individual.net>

The keywords are sum(), case when ... then ... else ... end, and group by.

Rene

> 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

-- 
  Rene Nyffenegger
  http://www.adp-gmbh.ch/
Received on Mon Mar 14 2005 - 13:10:36 CST

Original text of this message

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