[SQL] skip if latter value equal

2009-07-10 Thread Marcin Krawczyk
Hi list, I was wondering if it was possible for a field in SQL query to return NULL if latter value is exactly the same ? - for given ORDER BY clause, I guess. For example, query returns: xxyy 1 4 true xxyy 5 7 true xxyy 21 8 true yyzz 5 1 false yyzz 7 7 false yyzz 8 34 false I'd

Re: [SQL] skip if latter value equal

2009-07-10 Thread Pavel Stehule
Hello you can do it simply in new PostgreSQL 8.4. In older version the best way what I know is using a stored procedure, that returns table create or replace function foo() returns setof yourtablename as $$ declare r yourtablename; s yourtablename; result youratblename; first boolean =

Re: [SQL] skip if latter value equal

2009-07-10 Thread Marcin Krawczyk
Thanks a lot. pozdrowienia mk 2009/7/10 Pavel Stehule pavel.steh...@gmail.com Hello you can do it simply in new PostgreSQL 8.4. In older version the best way what I know is using a stored procedure, that returns table create or replace function foo() returns setof yourtablename as $$

[SQL] How update a table within a join efficiently ?

2009-07-10 Thread Andreas
Hi, how would I update a table within a join in a more efficient way? E.g. the folowing case: table_a holds abstract elements. One column represents priority which can be based on information of other tables. table_b might hold such details in a column size for about 3000 of 8 records out

Re: [SQL] How update a table within a join efficiently ?

2009-07-10 Thread Pavel Stehule
2009/7/10 Andreas maps...@gmx.net: Hi, how would I update a table within a join in a more efficient way? E.g. the folowing case: table_a holds abstract elements. One column represents priority which can be based on information of other tables. table_b might hold such details in a column

[SQL] WITH RECURSION output ordering with trees

2009-07-10 Thread Philippe Lang
Hi, I'm playing with the new WITH RECURSIVE feature of 8.4. I'm trying to figure out how to use it with trees. Here is the test code I use: - --DROP TABLE recursion; CREATE TABLE recursion ( id serial, lookup varchar(16), parent_id

Re: [SQL] WITH RECURSION output ordering with trees

2009-07-10 Thread Philippe Lang
pgsql-sql-ow...@postgresql.org wrote: Hi, I'm playing with the new WITH RECURSIVE feature of 8.4. I'm trying to figure out how to use it with trees. Here is the test code I use: - --DROP TABLE recursion; CREATE TABLE recursion

Re: [SQL] WITH RECURSION output ordering with trees

2009-07-10 Thread Thomas Kellerer
Philippe Lang, 10.07.2009 11:10: Hi, I'm playing with the new WITH RECURSIVE feature of 8.4. I'm trying to figure out how to use it with trees. Here is the test code I use: I'd like to perform a real recursion, and show the tree structure in a more appopriate way, like this: Any idea how to

Re: [SQL] WITH RECURSION output ordering with trees

2009-07-10 Thread Philippe Lang
pgsql-sql-ow...@postgresql.org wrote: Philippe Lang, 10.07.2009 11:10: Hi, I'm playing with the new WITH RECURSIVE feature of 8.4. I'm trying to figure out how to use it with trees. Here is the test code I use: I'd like to perform a real recursion, and show the tree structure in a

Re: [SQL] WITH RECURSION output ordering with trees

2009-07-10 Thread Harald Fuchs
In article e6a0649f1fbfa3408a37f505400e7ac215c...@email.attiksystem.ch, Philippe Lang philippe.l...@attiksystem.ch writes: Thanks for your answer. Si there a built-in function that would allow generating the sort path based on the value of the lookup column, instead of the id, which has no

Re: [SQL] WITH RECURSION output ordering with trees

2009-07-10 Thread Philippe Lang
pgsql-sql-ow...@postgresql.org wrote: In article e6a0649f1fbfa3408a37f505400e7ac215c...@email.attiksystem.ch, Philippe Lang philippe.l...@attiksystem.ch writes: Thanks for your answer. Si there a built-in function that would allow generating the sort path based on the value of the lookup