Re: [SQL] Self-Join

2011-12-06 Thread Bèrto ëd Sèra
Hi Abhinandan, I suppose you mean this: CREATE TABLE nav ( name varchar NOT NULL, attribute text NOT NULL, value numeric ); ALTER TABLE ONLY nav ADD CONSTRAINT nav_pkey PRIMARY KEY (name, attribute); insert into nav values ('James','Weight',70); insert into nav values ('James','Height',165); ins

Re: [SQL] Self-Join

2011-12-06 Thread Scott Swank
gt; Best, > Oliver > > - Original Message - From: "Scott Swank" > To: "Oliveiros d'Azevedo Cristina" > Cc: "Abhinandan Raghavan" ; > > Sent: Tuesday, December 06, 2011 5:17 PM > Subject: Re: [SQL] Self-Join > > > > H

Re: [SQL] Self-Join

2011-12-06 Thread Oliveiros d'Azevedo Cristina
I have not. I've already skimmed through it. Indeed, it is very interesting Thanx , Scott Best, Oliver - Original Message - From: "Scott Swank" To: "Oliveiros d'Azevedo Cristina" Cc: "Abhinandan Raghavan" ; Sent: Tuesday, December 06, 2

Re: [SQL] Self-Join

2011-12-06 Thread Scott Swank
a.name = b.name > AND b.attribute = 'Age' > GROUP BY a.name > ) age > > The thing is that it doesn't scale well if you have many more items beyond > three... > > Best, > Oliveiros > > - Original Message - > From: Abhinandan Raghavan > To: pgs

Re: [SQL] Self-Join

2011-12-06 Thread Oliveiros d'Azevedo Cristina
't scale well if you have many more items beyond three... Best, Oliveiros - Original Message - From: Abhinandan Raghavan To: pgsql-sql@postgresql.org Sent: Tuesday, December 06, 2011 1:57 PM Subject: [SQL] Self-Join Hi, I'm looking to frame an SQL statement

Re: [SQL] Self-Join

2011-12-06 Thread Bèrto ëd Sèra
Hi Abhinandan, it's just the same outer join you'd do in Oracle, see: http://www.postgresql.org/docs/9.1/static/tutorial-join.html Bèrto On 6 December 2011 16:57, Abhinandan Raghavan wrote: > Hi, > > I'm looking to frame an SQL statement in Postgres for what's explained in > the attached imag

[SQL] Self-Join

2011-12-06 Thread Abhinandan Raghavan
Hi, I'm looking to frame an SQL statement in Postgres for what's explained in the attached image. The original table is at the top and is called NAV (Short for Name, Attribute, Value). I want to create a view (NWHA_View) involving values from within (presumably from a self join). I would've

Re: [SQL] self join

2011-05-17 Thread Jasen Betts
On 2011-05-16, Steve Crawford wrote: > On 05/14/2011 07:36 PM, Jasen Betts wrote: >> >> use the "NOT IN" operator with a subquery to retch the disallowed >> values > Hmmm, "retch" as a synonym for "output"? I've seen more than one case > where that is an appropriate description. :) :) was

Re: [SQL] self join

2011-05-16 Thread Steve Crawford
On 05/14/2011 07:36 PM, Jasen Betts wrote: use the "NOT IN" operator with a subquery to retch the disallowed values Hmmm, "retch" as a synonym for "output"? I've seen more than one case where that is an appropriate description. :) Cheers, Steve -- Sent via pgsql-sql mailing list (pgsql-

Re: [SQL] self join

2011-05-15 Thread Harald Fuchs
In article , Jasen Betts writes: > On 2011-05-14, Seb wrote: >> Hi, >> >> This probably reflects my confusion with how self joins work. >> >> Suppose we have this table: >> If I want to get a table with records where none of the values in column >> b are found in column a, I thought this shou

Re: [SQL] self join

2011-05-14 Thread Jasen Betts
On 2011-05-14, Seb wrote: > Hi, > > This probably reflects my confusion with how self joins work. > > Suppose we have this table: > If I want to get a table with records where none of the values in column > b are found in column a, I thought this should do it: use the "NOT IN" operator with a su

Re: [SQL] self join

2011-05-14 Thread Seb
On Sun, 15 May 2011 07:39:06 +0900, Ian Lawrence Barwick wrote: [...] > Your query doesn't have an explicit join and is producing a cartesian > result. > I don't think a self- join will work here; a subquery should produce > the result you're after: > SELECT * FROM tmp t1 WHERE NOT EXISTS(SELE

Re: [SQL] self join

2011-05-14 Thread Ian Lawrence Barwick
Hi 2011/5/15 Seb : > Hi, > > This probably reflects my confusion with how self joins work. > > Suppose we have this table: > > =# SELECT * FROM tmp; >  a | b > ---+--- >  1 | 2 >  2 | 3 >  4 | 5 > (3 rows) > > If I want to get a table with records where none of the values in column > b are found i

[SQL] self join

2011-05-14 Thread Seb
Hi, This probably reflects my confusion with how self joins work. Suppose we have this table: =# SELECT * FROM tmp; a | b ---+--- 1 | 2 2 | 3 4 | 5 (3 rows) If I want to get a table with records where none of the values in column b are found in column a, I thought this should do it: =# SE

[SQL] Self Join?

2002-10-04 Thread bens_nospam
I'm having difficulty coming up with the right join to get my results. I'm using PostgreSQL 7.2.x I'm looking for a "most likely match" result. Assume you have a table with two fields, field 1 is a serial key (unique) and field 2 is varchar. Assume that you have the following entries in the