Re: [SQL] DISTINCT ON

2005-11-18 Thread Jeremy Palmer
> -Original Message- > From: Michael Glaesemann [mailto:[EMAIL PROTECTED] > Sent: Saturday, 19 November 2005 4:07 p.m. > To: Jeremy Palmer > Cc: pgsql-sql@postgresql.org > Subject: Re: [SQL] DISTINCT ON > > [Please don't top post. It makes the post harder to read. I've > reordered the post

Re: [SQL] DISTINCT ON

2005-11-18 Thread Michael Glaesemann
-Original Message- From: Michael Glaesemann [mailto:[EMAIL PROTECTED] Sent: Saturday, 19 November 2005 12:28 p.m. On Nov 19, 2005, at 7:49 , Jeremy Palmer wrote: SELECT DISTINCT ON (vector_id, obs_type) id FROM observation ORDER BY vector_id, obs_type, date

Re: [SQL] DISTINCT ON

2005-11-18 Thread Jeremy Palmer
Thanks for the reply. Unfortunately that does not work as "id" column needs to be included in the group by statement or be used in an aggregate function. If I did this it definitely would note return the correct answer, as the "id" column is the primary key for the table. Any further suggestions?

Re: [SQL] DISTINCT ON

2005-11-18 Thread Michael Glaesemann
On Nov 19, 2005, at 7:49 , Jeremy Palmer wrote: SELECT DISTINCT ON (vector_id, obs_type) id FROM observation ORDER BY vector_id, obs_type, date DESC; However the documentation also states that "DISTINCT ON" is not part of the SQL standard and should be avoided when po

[SQL] DISTINCT ON

2005-11-18 Thread Jeremy Palmer
Hi, I have a table: observation ( id int4 NOT NULL [PRIMARY KEY], vector_id NOT NULL [FORGIEN KEY], obs_type VARCHAR(4) NOT NULL, date TIMESTAMP NULL ) I need to select the newest observation id, classify by type, for each vector (there can be multiple observation ids on each vector)

Re: [SQL] Export to XML

2005-11-18 Thread Dean Gibson (DB Administrator)
On 2005-11-11 10:26, Warren Murray wrote: What is the process to export a PostgreSQL table to XML? How is it done? Thanks! Two ways using PSQL: 1. Select HTML output ("\H" command) and then do a very minor amount of post processing (details left to the reader). 2. Select "expanded" outp

[SQL] idea for a geographically distributed database: how best to implement?

2005-11-18 Thread Andy Ballingall
Hello,   I’ve got a database for a website which is a variant of the ‘show stuff near to me’ sort of thing.   Rather than host this database on a single server, I have a scheme in mind to break the database up geographically so that each one can run comfortably on a small server, but I’

[SQL] [postgres] pgcluster

2005-11-18 Thread Stephan Fischer
Hi, ich bin dabei DB-Server zu einem Cluster zusammen zuführen mit PGCLUSTER. Hat schon jemand von euch damit gearbeitet und kann mir mal seine Meinung/Erfahrung dazu sagen (positiv oder negativ). Werde auch meine Erfahrung noch Erfolg hier mal posten. Server: 7.4.1 (suse9.0) pgcluster-1.1 Grüs

[SQL] Export to XML

2005-11-18 Thread Warren Murray
What is the process to export a PostgreSQL table to XML? How is it done? Thanks! Warren L Murray Booz Allen Hamilton Phone: 404.518.7940 Email: [EMAIL PROTECTED] ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] idea for a geographically distributed database: how best to implement?

2005-11-18 Thread Andrew Sullivan
On Fri, Nov 18, 2005 at 09:09:24AM -, Andy Ballingall wrote: > That's very interesting! I've not used slony yet, so I'll setup some tests > and try exactly this mechanism. If you do this with Slony, and have any success, I know that the folks on the Slony list would dearly like to hear about i

Re: [SQL] how to do a find and replace

2005-11-18 Thread Andrew Sullivan
On Thu, Nov 17, 2005 at 02:51:05PM -0800, Dawn Buie wrote: > I'm just confused about how I should write code to update the selected > items to remove the 'v.' > > Would I use substring? An example would be much appreciated. You need a combination of overlay and location. The following will work

Re: [SQL] idea for a geographically distributed database: how best to implement?

2005-11-18 Thread Andy Ballingall
Thanks Aidan, That's very interesting! I've not used slony yet, so I'll setup some tests and try exactly this mechanism. What I like about it is that the changes that have to occur to either add a cell or to split an existing cell into two to manage growing traffic have a localised effect on the

[SQL] query

2005-11-18 Thread Aftab Alam
Hello, I want to create a trigger in PostgresSQL In trigger, Before inserting the record, if data is already in the table, the trigger fire the mesaage that data is already there, and after that trigger ckeck for next insert statement. How can I do this , Please reply. Regards, _ Aftab