|
|
Re: Conditionally display previous values [message #289864 is a reply to message #289851] |
Wed, 26 December 2007 05:23 |
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
|
|
|
|