Thanks Dieter it is working fine.. below is the query i had done...
SEL * FROM
(SEL MATURITY,TIMEPD, ROW_NUMBER() OVER(PARTITION BY MATURITY ORDER BY TIMEPD DESC) RN FROM DTFD WHERE MATURITY>TIMEPD
UNION ALL
SEL MATURITY,TIMEPD, ROW_NUMBER() OVER(PARTITION BY MATURITY ORDER BY TIMEPD ) FROM DTFD
WHERE MATURITY<TIMEPD)T
QUALIFY ROW_NUMBER() OVER(PARTITION BY MATURITY ORDER BY MATURITY,RN)<=2
↧