Home » SQL & PL/SQL » SQL & PL/SQL » QUERY HELP (ORACLE 11G)
QUERY HELP [message #655482] Wed, 31 August 2016 14:56 Go to next message
DivP
Messages: 2
Registered: August 2016
Junior Member
Hello,

I need help in query.

I have below data.

NO AMOUNT OFFSET
----------------------
1 100 5
2 NULL 6
3 NULL 4
4 NULL 3

I NEED OUTPUT LIKE BELOW

NO AMOUNT OFFSET
-----------------------
1 100 5
2 105(100+5) 6
3 111(105+6) 4
4 115(111+4) 3


Can any one please help?
I need to know if it can be done via a query.

__Div
Re: QUERY HELP [message #655484 is a reply to message #655482] Wed, 31 August 2016 15:06 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Welcome to this forum

Please read and follow the forum guidelines, to enable us to help you:
OraFAQ Forum Guide
How to use {code} tags and make your code easier to read

Re: QUERY HELP [message #655485 is a reply to message #655482] Wed, 31 August 2016 15:07 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
Welcome to the forum. Please read our OraFAQ Forum Guide and How to use [code] tags and make your code easier to read

You need to provide the CREATE TABLE and INSERT statements to set up the problem. You also need to show what SQL you have tried so far. Is this a college homework assignment?
Re: QUERY HELP [message #655487 is a reply to message #655482] Wed, 31 August 2016 15:08 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Welcome to the forum.
Please read OraFAQ Forum Guide and How to use [code] tags and make your code easier to read.
Also always post your Oracle version, with 4 decimals, as solution depends on it.

With any SQL or PL/SQL question, please, Post a working Test case: create table (including all constraints) and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.

Use SUM in its analytic form.
Here's an example with standard EMP table:
SQL> select ename, sal,
  2         sum(sal) over (order by ename rows between unbounded preceding and 1 preceding) prev_sum
  3  from emp
  4  order by ename
  5  /

ENAME             SAL   PREV_SUM
---------- ---------- ----------
ADAMS            1100
ALLEN            1600       1100
BLAKE            2850       2700
CLARK            2450       5550
FORD             3000       8000
JAMES             950      11000
JONES            2975      11950
KING             5000      14925
MARTIN           1250      19925
MILLER           1300      21175
SCOTT            3000      22475
SMITH             800      25475
TURNER           1500      26275
WARD             1250      27775
Re: QUERY HELP [message #655488 is a reply to message #655487] Wed, 31 August 2016 15:16 Go to previous message
DivP
Messages: 2
Registered: August 2016
Junior Member
Thanks.. It helps ..
Previous Topic: finding previous quarter end date
Next Topic: Query to find special alphabets
Goto Forum:
  


Current Time: Fri Apr 26 12:57:33 CDT 2024