Re: [GENERAL] a question on SQL

2006-12-13 Thread Gregory S. Williamson
Bruce Momjian wrote: > > Tom Lane wrote: > > "Greg Sabino Mullane" <[EMAIL PROTECTED]> writes: > > >> It's the single most useful non-standard SQL feature postgresql has. It > > >> is thus simultaneously bad (from a portatbility aspect) and brilliant > > >> (because it's a million times easier and

Re: [GENERAL] a question on SQL

2006-12-13 Thread Bruce Momjian
Tom Lane wrote: > "Greg Sabino Mullane" <[EMAIL PROTECTED]> writes: > >> It's the single most useful non-standard SQL feature postgresql has. It > >> is thus simultaneously bad (from a portatbility aspect) and brilliant > >> (because it's a million times easier and faster than the alternatives). >

Re: [GENERAL] a question on SQL

2006-12-12 Thread Tom Lane
"Greg Sabino Mullane" <[EMAIL PROTECTED]> writes: >> It's the single most useful non-standard SQL feature postgresql has. It >> is thus simultaneously bad (from a portatbility aspect) and brilliant >> (because it's a million times easier and faster than the alternatives). > You mean second-most us

Re: [GENERAL] a question on SQL

2006-12-12 Thread Greg Sabino Mullane
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 >> Ragnar, Marc, thanks so much for the help: DISTINCT ON was *exactly* >> what I needed. >> It's not a part of any SQL standard I know of, but does the job >> _wonderfully_. > It's the single most useful non-standard SQL feature postgresql has. It

Re: [GENERAL] a question on SQL

2006-12-12 Thread Martijn van Oosterhout
On Tue, Dec 12, 2006 at 06:29:07PM +, Tomi N/A wrote: > Ragnar, Marc, thanks so much for the help: DISTINCT ON was *exactly* > what I needed. > It's not a part of any SQL standard I know of, but does the job > _wonderfully_. It's the single most useful non-standard SQL feature postgresql has.

Re: [GENERAL] a question on SQL

2006-12-12 Thread Tomi N/A
Ragnar, Marc, thanks so much for the help: DISTINCT ON was *exactly* what I needed. It's not a part of any SQL standard I know of, but does the job _wonderfully_. Cheers, t.n.a. ---(end of broadcast)--- TIP 4: Have you searched our list archives?

Re: [GENERAL] a question on SQL

2006-12-12 Thread Marc Mamin
Seems that a recursive use of "DISTINCT ON" will do it: create table factories (id int, factory varchar(10), ownerid int); create table products (id int, product varchar(10), atime int ,factory_id int); --owner 1 : factory 1 insert into products values(1,'p1',123,1); insert into products value

Re: [GENERAL] a question on SQL

2006-12-12 Thread Ragnar
On þri, 2006-12-12 at 16:47 +, Tomi N/A wrote: > Don't really know where to ask this...the general mailing list sounds > like the closest. > > Let's say I have three tables: owner, factory and product with a 1:N > relationship at each step. > Assuming that a product has a production date, how

[GENERAL] a question on SQL

2006-12-12 Thread Tomi N/A
Don't really know where to ask this...the general mailing list sounds like the closest. Let's say I have three tables: owner, factory and product with a 1:N relationship at each step. Assuming that a product has a production date, how would you go about returning a factory for every owner, where