Home » SQL & PL/SQL » SQL & PL/SQL » Sql to get previous row value (Oracle 10g, O/S Win XP)
Sql to get previous row value [message #434563] Wed, 09 December 2009 13:54 Go to next message
Messages: 14
Registered: January 2009
Location: USA
Junior Member

I will appreciate if you please can help me. Please see my attached pdf. Field Price_Break and Break_cost comes from the table itself. I have to display the Break comment (in red)using sql.

To display the Break_comment, for the first record, it is 1 ~ 4 i.e. quantity 1 ro 4 it is price $ 420.00

For the second record, it is first level + 1 ie. (4+10) 5 ~ 24 price is $80.2

For the third record, level second + 1 ie. (24+1) 25 ~ 49 price is $79.32

How do I do it?

N.B. The sql I put at the attachment did not generate the result set. I manually typed the break_comment format the way I want.

  • Attachment: sql.pdf
    (Size: 31.67KB, Downloaded 324 times)

[Updated on: Wed, 09 December 2009 14:01]

Report message to a moderator

Re: Sql to get previous row value [message #434565 is a reply to message #434563] Wed, 09 December 2009 14:03 Go to previous messageGo to next message
Messages: 25543
Registered: January 2009
Location: SoCal
Senior Member
>Sql to get previous row value
use LAG function

Please SEARCH this forum for FAQ examples.

You need to help us by following the Posting Guidelines as stated below.
Go to the URL above click the link "Posting Guidelines"
Go to the section labeled "Practice" & do as directed.
Re: Sql to get previous row value [message #434566 is a reply to message #434563] Wed, 09 December 2009 14:14 Go to previous message
Michel Cadot
Messages: 65088
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I remind you this post from your previous post:
Michel Cadot wrote on Tue, 30 June 2009 17:54
Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Use code tags and the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Use SQL*Plus and copy and paste your session.


Previous Topic: Regarding Procedure Troubleshooting
Next Topic: UTL_SMTP inline and attachment issue
Goto Forum:

Current Time: Thu Jul 27 00:16:24 CDT 2017

Total time taken to generate the page: 0.07689 seconds