Re: Complex query
| От | Leonardo M. Ramé |
|---|---|
| Тема | Re: Complex query |
| Дата | |
| Msg-id | 20140331192242.GD10833@leonardo-laptop обсуждение исходный текст |
| Ответ на | Re: Complex query (David Johnston <polobo@yahoo.com>) |
| Список | pgsql-general |
On 2014-03-31 12:16:53 -0700, David Johnston wrote: > Leonardo M. Ramé-2 wrote > > select lag.id, lag.idtask, lag.code, lag.lg from (select idtask, code, id, > > lag(code, -1) over () as lg from tasks_test) as lag > > First you want to include an ORDER BY in the OVER(...) clause, and probably > a PARTITION BY as well. > > Then you move that to a sub-query (for example): > > SELECT * > FROM tbl > WHERE tbl.idtask IN ( > SELECT lag.idtask FROM ( lag_query_here ) lag WHERE lag.code = 'T' and > lag.lg = 'S' > ); > > David J. > Great!, that's what I needed, thank you. -- Leonardo M. Ramé Medical IT - Griensu S.A. Av. Colón 636 - Piso 8 Of. A X5000EPT -- Córdoba Tel.: +54(351)4246924 +54(351)4247788 +54(351)4247979 int. 19 Cel.: +54 9 (011) 40871877
В списке pgsql-general по дате отправления: