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

From: "Oliveiros d'Azevedo Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "Mark King" <fires10(at)gmail(dot)com>, <pgsql-novice(at)postgresql(dot)org>
Subject: Re: can a function take a column name or is there another solution
Date: 2011-04-18 15:35:19
Message-ID: 6B57806AD25A4B81A81A7B6EE5889601@marktestcr.marktest.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello!

I fail to understand what you are attempting to do.
What does your table represent and what output you expect to have..?

To my best knowledge this (select meter1 where sampledate = sampledate + interval '1 days') is not valid SQL so could you please explain in english the info
you want to obtain from your table?

Best,
Oliveiros

----- Original Message -----
From: Mark King
To: pgsql-novice(at)postgresql(dot)org
Sent: Monday, April 18, 2011 4:16 PM
Subject: [NOVICE] can a function take a column name or is there another solution

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?

Mark King

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2011-04-18 15:37:50 Re: can a function take a column name or is there another solution
Previous Message Mark King 2011-04-18 15:16:28 can a function take a column name or is there another solution