Re: can a function take a column name or is there another solution

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: can a function take a column name or is there another solution
Дата
Msg-id 22946.1303141070@sss.pgh.pa.us
обсуждение исходный текст
Ответ на can a function take a column name or is there another solution  (Mark King <fires10@gmail.com>)
Ответы Re: can a function take a column name or is there another solution  (Mark King <fires10@gmail.com>)
Список pgsql-novice
Mark King <fires10@gmail.com> writes:
> I have a table with sampledate, meter1, meter2...etc
> I am trying to develop a function or query

> where:

> select sampledate, (meter1 - (select meter1 where sampledate = sampledate +
> interval '1 days')) as consumption from mytable;

> Any ideas how to make this work?

I think what you're looking for is window functions, specifically the
LEAD/LAG functions.  You need Postgres >= 8.4 for those though.

            regards, tom lane

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

Предыдущее
От: "Oliveiros d'Azevedo Cristina"
Дата:
Сообщение: Re: can a function take a column name or is there another solution
Следующее
От: Mark King
Дата:
Сообщение: Re: can a function take a column name or is there another solution