Re: [SQL] Filtering data based on timestamp

2006-02-07 Thread Richard Huxton
Panos Kassianidis wrote: Thanks very much for the answer. Could you also please tell me how am I supposed to write such a function? How is date_trunc implemented so that I can extend it? In C in SQL? I'd probably write it in plpgsql unless you need the speed. And where can I find its source c

Re: [SQL] Filtering data based on timestamp

2006-02-07 Thread Richard Huxton
Panos Kassianidis wrote: and I would like to retrieve values recorded in the last 2 hours but with an interval of 5 minutes, which means that my query should return one tuple for every 5 tuples in the table and the value of this tuple should be an average of 5 values. Does anyone have any clue ho

[SQL] Filtering data based on timestamp

2006-02-07 Thread Panos Kassianidis
Hello everybody, I am building a data logging application and I am facing the following problem. I have a table which holds timestamp-value pairs for a recorded variable. I would like to be able to select a range of values between a starting and an ending timestamp but also specify an interval

Re: [SQL] filtering after join

2006-01-27 Thread andrew
I have traced the code. It exits when the argument is the result of a join or a subselect in function ParseFuncOrColumn(). The reason mentioned in the comments is lack of named tuple type. How can force it to create such a tuple type? is there a way? thanks a million times! On 1/27/06, Tom Lane <

Re: [SQL] filtering after join

2006-01-27 Thread andrew
Sorry. I am working on a research prototype built on 7.3 which contains a cosiderable amount of efforts. The original developers of the prototype have no interest in upgrading it. It is also impossible for me to upgrade it by myself. Could you give me any tips to sovle the current problem? Thanks!

Re: [SQL] filtering after join

2006-01-27 Thread Tom Lane
andrew <[EMAIL PROTECTED]> writes: > I got errors in this query. I have a function complete(record) which > takes a generic record type data. But it seems cannot be applied to a > sub-select result: As I seem to recall having mentioned several times already, PG 7.3 is really, really weak in this a

Re: [SQL] filtering after join

2006-01-27 Thread andrew
I got errors in this query. I have a function complete(record) which takes a generic record type data. But it seems cannot be applied to a sub-select result: backend> explain select * from (select * from Person,Auction where Person.id=Auction.seller) as s where complete(s) QUERY: explain select *

Re: [SQL] filtering after join

2006-01-27 Thread andrew
I can see the final plan by using the EXPLAIN command. But I want to know the procedure of the planner in handling nesting queries. Can you direct me to the corresponding part of the code and/or the documents? Thanks. On 1/26/06, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > andrew wrote: > > How

Re: [SQL] filtering after join

2006-01-26 Thread Peter Eisentraut
andrew wrote: > How will the query planner do for a nesting query? Treat the > subqueries as multiple queries and then link them together? > where can I find the information (codes or documents)? Look at the execution plan using the EXPLAIN command. -- Peter Eisentraut http://developer.postgresq

Re: [SQL] filtering after join

2006-01-26 Thread andrew
How will the query planner do for a nesting query? Treat the subqueries as multiple queries and then link them together? where can I find the information (codes or documents)? Thanks. On 1/26/06, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > andrew wrote: > > But the function foo() would produce di

Re: [SQL] filtering after join

2006-01-26 Thread Peter Eisentraut
andrew wrote: > But the function foo() would produce different values for the two > queries, so the result will be different. > A simple example is foo() computes the sum of all the integer fields > of the input record. OK, I see now where you're getting at. You want to combine the record type o

Re: [SQL] filtering after join

2006-01-26 Thread andrew
But the function foo() would produce different values for the two queries, so the result will be different. A simple example is foo() computes the sum of all the integer fields of the input record. On 1/26/06, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > andrew wrote: > > Sorry for the confusion.

Re: [SQL] filtering after join

2006-01-26 Thread Peter Eisentraut
andrew wrote: > Sorry for the confusion. This is what i meant. Thanks, Michael. > > select * > from (select * from A, B where A.a = B.b) as s > where foo(s) < 2; > > On 1/25/06, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > > andrew wrote: > > > I want to use a UDF to filter tuples t that are gener

Re: [SQL] filtering after join

2006-01-25 Thread andrew
Sorry for the confusion. This is what i meant. Thanks, Michael. select * from (select * from A, B where A.a = B.b) as s where foo(s) < 2; On 1/25/06, Peter Eisentraut <[EMAIL PROTECTED]> wrote: > andrew wrote: > > I want to use a UDF to filter tuples t that are generated after a > > join. More sp

Re: [SQL] filtering after join

2006-01-25 Thread Peter Eisentraut
andrew wrote: > I want to use a UDF to filter tuples t that are generated after a > join. More specifially, I have a UDF foo(record), which computes a > value for a given tuple. I can do the filtering before the join. > e.g.: > > select * from A, B where foo(A)<2 and A.a=B.b; What makes you think

Re: [SQL] filtering after join

2006-01-25 Thread Michael Fuhr
On Wed, Jan 25, 2006 at 06:27:33PM +0100, andrew wrote: > I want to use a UDF to filter tuples t that are generated after a join. > More specifially, I have a UDF foo(record), which computes a value for > a given tuple. I can do the filtering before the join. e.g.: > > select * from A, B where fo

[SQL] filtering after join

2006-01-25 Thread andrew
I want to use a UDF to filter tuples t that are generated after a join. More specifially, I have a UDF foo(record), which computes a value for a given tuple. I can do the filtering before the join. e.g.: select * from A, B where foo(A)<2 and A.a=B.b; But I want to apply foo() to the tuples gener

Re: [SQL] filtering

2004-12-11 Thread Bruno Wolff III
On Thu, Dec 09, 2004 at 10:25:25 -0500, "Kevin B." <[EMAIL PROTECTED]> wrote: > Hi, > > I have a 14 million row table with one index on two fields one is a varchar > the other is a date. The combination of the two makes the row unique. > > Data > - > name date... other fie

[SQL] filtering

2004-12-10 Thread Kevin B.
Hi, I have a 14 million row table with one index on two fields one is a varchar the other is a date. The combination of the two makes the row unique. Data - name date... other fields a 1/1/01 a 1/2/01 a 1/3/01 b 1/1/01 b 1/2/01 d 1/1/01 d 1/2/01