Home » Developer & Programmer » Reports & Discoverer » sum a column according to a previous row in the report
sum a column according to a previous row in the report [message #268073] Mon, 17 September 2007 07:54 Go to next message
emadbsb
Messages: 334
Registered: May 2005
Location: egypt
Senior Member

hii all

suppose i have this rows generated in a report

a b
5 8
10 12
8 20


i put any values for b as "b" should be equal to
a in the current row + b in the previous row

so that the result should be like this

a b
5 5
10 15 ====>(10+5)
8 23 ====>(8+15)


how can i do this in a report

Re: sum a column according to a previous row in the report [message #268087 is a reply to message #268073] Mon, 17 September 2007 08:51 Go to previous messageGo to next message
vamsi kasina
Messages: 2112
Registered: October 2003
Location: Cincinnati, OH
Senior Member
Search for Analytical functions (LAG).

By
Vamsi
Re: sum a column according to a previous row in the report [message #268120 is a reply to message #268087] Mon, 17 September 2007 10:33 Go to previous message
Soumen Kamilya
Messages: 128
Registered: August 2007
Location: Kolkata
Senior Member

select a, a+ nvl(lag(b) over(order by a),0) as b from <table_name>


Cheers
Soumen

[Updated on: Mon, 17 September 2007 10:39]

Report message to a moderator

Previous Topic: CSV format for report
Next Topic: Order by in a Group Matrix Report
Goto Forum:
  


Current Time: Fri Jul 05 05:43:37 CDT 2024