---
title: "分析函数一例"
author: "kebo"
date: "2007-07-17T16:55:00Z"
tags: []
slug: "untitled"
draft: false
lastmod: "2007-07-17T16:55:00Z"
id: 255023
url: "https://kebo.iteye.com/blog/255023"
---

select z.a,z.b,z.c from (select lag(t.a,2)over(order by t.a) pp\_val, lag(t.a,1)over(order by t.a) p\_val, t.a, lead(t.a,1)over(order by t.a) n\_val, lead(t.a,2)over(order by t.a) nn\_val, t.b,t.c from test2 t) z where z.a = '1' and ((z.p\_val = '1' and z.pp\_val = '1') or (z.p\_val = '1' and z.n\_val = '1') or (z.n\_val = '1' and z.nn\_val = '1'));