Home » SQL & PL/SQL » SQL & PL/SQL » Compare the value with previous row
Compare the value with previous row [message #327720] Tue, 17 June 2008 06:30 Go to next message
atozvs
Messages: 12
Registered: May 2008
Location: Hyderabad
Junior Member
HI,

In a simple emp table, i need to display the row if the salary is more than the previous rows sal value.

Can you explain the query for this.

Thanks
VS
Re: Compare the value with previous row [message #327722 is a reply to message #327720] Tue, 17 June 2008 06:33 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
Study Analytical Functions in Oracle.
Re: Compare the value with previous row [message #327723 is a reply to message #327720] Tue, 17 June 2008 06:34 Go to previous messageGo to next message
Michel Cadot
Messages: 64119
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
if the salary is more than the previous rows sal value

Define "previous".

Then have a look at LEAD/LAG functions.

Regards
Michel

[Updated on: Tue, 17 June 2008 06:35]

Report message to a moderator

Re: Compare the value with previous row [message #327727 is a reply to message #327722] Tue, 17 June 2008 06:38 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
http://www.akadia.com/services/ora_analytic_functions.html

Check For LAG and LEAD Functions.

Cheers,
Rajat Ratewal
Re: Compare the value with previous row [message #327731 is a reply to message #327727] Tue, 17 June 2008 06:58 Go to previous messageGo to next message
Michel Cadot
Messages: 64119
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You should review your link you posted several times, it points to OraFAQ home page and so is not very useful.

Regards
Michel
Re: Compare the value with previous row [message #327733 is a reply to message #327731] Tue, 17 June 2008 07:03 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
Michel I had Checked it.But don't know what went wrong.

please find the link.

http://www.akadia.com/services/ora_analytic_functions.html

Regards,
Rajat Ratewal
Re: Compare the value with previous row [message #327737 is a reply to message #327733] Tue, 17 June 2008 07:16 Go to previous messageGo to next message
Michel Cadot
Messages: 64119
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
It better works.
In the previous post the link actually points to: http://www.orafaq.com/forum/AnalyticalFunctions
which does not exist.

Regards
Michel


Re: Compare the value with previous row [message #327747 is a reply to message #327737] Tue, 17 June 2008 07:34 Go to previous messageGo to next message
rajatratewal
Messages: 507
Registered: March 2008
Location: INDIA
Senior Member
Thanks For Pointing out Michel.

I will keep that in mind next time.

Regards,
Rajat Ratewal
Re: Compare the value with previous row [message #327765 is a reply to message #327747] Tue, 17 June 2008 08:54 Go to previous message
atozvs
Messages: 12
Registered: May 2008
Location: Hyderabad
Junior Member
Thanks for the info

I will review the Anaytic functions and will get back, if still i have any doubts.

thanks once again!
Previous Topic: Not able to understand this Query
Next Topic: Problem accessing external tables over network
Goto Forum:
  


Current Time: Tue Dec 06 06:51:42 CST 2016

Total time taken to generate the page: 0.12474 seconds