Home » Other » Training & Certification » Conditionally display previous values (UNKNOWN OS/VERSION)
Conditionally display previous values [message #289825] Wed, 26 December 2007 04:06 Go to next message
pavuluri
Messages: 247
Registered: January 2007
Senior Member
Hi all

i have comm

comm
0
0
500
0
0
0
600
0
700
0
0
0


out put is
comm
0
0
500
500
500
500
600
600
700
700
700
700


thanks
srinivas

[mod-edit]Modified title.

[Updated on: Wed, 26 December 2007 04:46] by Moderator

Report message to a moderator

Re: Conditionally display previous values [message #289851 is a reply to message #289825] Wed, 26 December 2007 04:57 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
LAG

Regards
Michel
Re: Conditionally display previous values [message #289864 is a reply to message #289851] Wed, 26 December 2007 05:23 Go to previous messageGo to next message
pavuluri
Messages: 247
Registered: January 2007
Senior Member
uw know lag and lead syntax

SELECT deptno, ename, hiredate,
LAG(hiredate,1,NULL)
OVER (PARTITION BY deptno
ORDER BY hiredate, ename) last_hire,
hiredate - LAG(hiredate,1,NULL)
OVER (PARTITION BY deptno
ORDER BY hiredate, ename) days_last,
LEAD(hiredate,1,NULL)
OVER (PARTITION BY deptno
ORDER BY hiredate, ename) next_hire,
LEAD(hiredate,1,NULL)
OVER (PARTITION BY deptno
ORDER BY hiredate, ename) - hiredate days_next
FROM emp
ORDER BY deptno, hiredate

thnaks
srinivas
Re: Conditionally display previous values [message #289867 is a reply to message #289864] Wed, 26 December 2007 05:53 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Is this a question or a solution?

Read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.

Regards
Michel
Previous Topic: SQL Tuning
Next Topic: increment months
Goto Forum:
  


Current Time: Sun Nov 24 02:14:48 CST 2024