Обсуждение: double linked list
Hi folks!, I've got a table called 'link_t' containing a collection of seller - buyer relations between two parties. sql> select * from link_t S B - - C X A B B C C D D E 5 rows selected. I am looking for a select statement that returns the concatenation of seller - buyer relations between the first seller 'A' and the last buyer 'B'. the result should be S B - - A B B C C D D E Currently I fumbling around with self joins but haven't figured out yet. Any suggestions Many tanks in advance Cheers Juergen
Juergen wrote: > Hi folks!, > > I've got a table called 'link_t' containing a collection of seller - > buyer relations between two parties. > > sql> select * from link_t > > S B > - - > C X > A B > B C > C D > D E > > 5 rows selected. > > I am looking for a select statement that returns the concatenation of > seller - buyer relations between the first seller 'A' and the last > buyer 'B'. > > the result should be > > S B > - - > A B > B C > C D > D E > > Currently I fumbling around with self joins but haven't figured out > yet. > Any suggestions > > Many tanks in advance > > Cheers > > Juergen Look at the CONNECT BY built-in function. Daniel Morgan
I've seen CELKO's reply and find it very useful. But I cannot find anything about > BEGIN ATOMIC > DECLARE rightmost_spread INTEGER; > > SET rightmost_spread > = (SELECT rgt > FROM Frammis > WHERE part = 'G'); > ... Is this PostgreSQL at all? Any hints welcome. Regards, Christoph
On Thursday 30 January 2003 07:10, Christoph Haller wrote: > I've seen CELKO's reply and find it very useful. > But I cannot find anything about > > > BEGIN ATOMIC > > DECLARE rightmost_spread INTEGER; > > > > SET rightmost_spread > > = (SELECT rgt > > FROM Frammis > > WHERE part = 'G'); > > ... > > Is this PostgreSQL at all? Any hints welcome. Mr Haller No, this is a dialect SQL-92 (SQL-99?) that Mr Celko uses for his examples since his solutions are vendor nutral. He is big on standards, so posting using the standard is his way of boosting them. BEGIN ATOMIC is BEGIN in PG. I am not sure how to declare a variable in PG in normal SQL. I don't do it that often, but when I do I do this: CREATE TEMPORARY TABLE Rightmost_Spread AS SELECT rightmost_spread FROM Frammis WHERE part = 'G'; I wonder what the alterntatives are? Alan Gutierrez - ajglist@izzy.net http://khtml-win32.sourceforge.net/ - KHTML on Windows
> > On Thursday 30 January 2003 07:10, Christoph Haller wrote: > > I've seen CELKO's reply and find it very useful. > > But I cannot find anything about > > > > > BEGIN ATOMIC > > > DECLARE rightmost_spread INTEGER; > > > > > > SET rightmost_spread > > > =3D (SELECT rgt > > > FROM Frammis > > > WHERE part = 'G'); > > > ... > > > > Is this PostgreSQL at all? Any hints welcome. > > Mr Haller > > No, this is a dialect SQL-92 (SQL-99?) that Mr Celko uses for his > examples since his solutions are vendor neutral. He is big on standards, > so posting using the standard is his way of boosting them. > > BEGIN ATOMIC is BEGIN in PG. > > I am not sure how to declare a variable in PG in normal SQL. I don't do > it that often, but when I do I do this: > > CREATE TEMPORARY TABLE Rightmost_Spread > AS SELECT rightmost_spread > FROM Frammis > WHERE part = 'G'; > > I wonder what the alternatives are? > plpgsql is the best I can think of. And thanks for the quick reply. Regards, Christoph