Re: [SQL] Table Design for Hierarchical Data

2010-04-08 Thread Achilleas Mantzios
Στις Wednesday 07 April 2010 23:33:07 ο/η Yeb Havinga έγραψε: > Achilleas Mantzios wrote: > > Στις Wednesday 07 April 2010 11:06:44 ο/η Yeb Havinga έγραψε: > > > >> Achilleas Mantzios wrote: > >> > >>> You could also consider the genealogical approach, e.g. > >>> > >>> > >>> The parents of

Re: [SQL] Table Design for Hierarchical Data

2010-04-08 Thread Yeb Havinga
Achilleas Mantzios wrote: Στις Wednesday 07 April 2010 23:33:07 ο/η Yeb Havinga έγραψε: Achilleas Mantzios wrote: Στις Wednesday 07 April 2010 11:06:44 ο/η Yeb Havinga έγραψε: Achilleas Mantzios wrote: You could also consider the genealogical approach, e.g. T

[SQL] Problem with function returning a result set

2010-04-08 Thread Thomas Kellerer
Hi, I'm playing around with functions returning result sets, and I have a problem with the following function: -- Create sample data CREATE TABLE employee (id integer, first_name varchar(50), last_name varchar(50)); INSERT INTO employee values (1, 'Arthur', 'Dent'); INSERT INTO employee values

Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Tom Lane
Thomas Kellerer writes: > CREATE OR REPLACE FUNCTION get_employees(name_pattern varchar) > RETURNS TABLE(id integer, full_name text) > AS > $$ > BEGIN >RETURN QUERY > SELECT id, first_name||' '||last_name > FROM employee > WHERE last_name LIKE name_pattern ||'%'; > END > $$ > L

Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Pavel Stehule
2010/4/8 Thomas Kellerer : > Hi, > > I'm playing around with functions returning result sets, and I have a > problem with the following function: > > -- Create sample data > CREATE TABLE employee (id integer, first_name varchar(50), last_name > varchar(50)); > INSERT INTO employee values (1, 'Arthu

Re: [SQL] Problem with function returning a result set

2010-04-08 Thread Thomas Kellerer
Tom Lane, 08.04.2010 10:59: Thomas Kellerer writes: CREATE OR REPLACE FUNCTION get_employees(name_pattern varchar) RETURNS TABLE(id integer, full_name text) AS $$ BEGIN RETURN QUERY SELECT id, first_name||' '||last_name FROM employee WHERE last_name LIKE name_pattern ||

Re: [SQL] Table Design for Hierarchical Data

2010-04-08 Thread Rob Sargent
The "parent" node in a genealogy is the mother-father tuple, so given that as a singularity it still fits a tree. On 04/08/2010 12:56 AM, Achilleas Mantzios wrote: > Στις Wednesday 07 April 2010 23:33:07 ο/η Yeb Havinga έγραψε: >> Achilleas Mantzios wrote: >>> Στις Wednesday 07 April 2010 11:06:44

[SQL] Howto get a group_number like row_number for groups

2010-04-08 Thread Andreas
Hi I'd like to have an alternating colorindex in the output of a query that consecutive rows that are the same within a colum the same number. The query generates a readable output from a log-table and a few others that hold referenced texts. log (log_id int, log_event_fk int, object_fk i

Re: [SQL] Howto get a group_number like row_number for groups

2010-04-08 Thread Jaime Casanova
On Thu, Apr 8, 2010 at 2:51 PM, Andreas wrote: > or rank()  over  (order by  object,   ts)  %  2 use dense_rank() instead -- Atentamente, Jaime Casanova Soporte y capacitación de PostgreSQL Asesoría y desarrollo de sistemas Guayaquil - Ecuador Cel. +59387171157 -- Sent via pgsql-sql mailing l