Compare rows

Поиск
Список
Период
Сортировка
От LALIT KUMAR
Тема Compare rows
Дата
Msg-id CAMojEG+D5uNfiE5ChJp37pbJVQsB007S9WYo-GonmbNR04tFrA@mail.gmail.com
обсуждение исходный текст
Ответы Re: Compare rows  (Thom Brown <thom@linux.com>)
Re: Compare rows  (Thom Brown <thom@linux.com>)
Список pgsql-novice
Hi,
I have the following table.

city    Rate         flag
A         10             0
A         20             1
A         30              0
A          2              0
A         23              1
A        12               0
B          5               1
B          43              0
C         23                1
C        67                 1

For every city I have so set the  flag as -1 in row which is 0 above the row having flag as 1.

So my out would be:

city    Rate         flag
A         10             -1
A         20             1
A         30              0
A          2              -1
A         23              1   (not changed to -1 as it not 0)
A        12               0  (not changed to -1 because i need to compare  it to row of same city. so being last row not compared with any row)
----------------------------------------------------
B          5               1
B          43              
C         23                1
C        67                 1

В списке pgsql-novice по дате отправления:

Предыдущее
От: "Greg Sabino Mullane"
Дата:
Сообщение: Re: pgpass.cong file becomes empty
Следующее
От: Thom Brown
Дата:
Сообщение: Re: Compare rows