Re: [SQL] Finding sequential records

2008-09-26 Thread Richard Broersma
On Fri, Sep 26, 2008 at 3:25 PM, Steve Midgley <[EMAIL PROTECTED]> wrote: > This returns an error: > > ERROR: column "dummy.id" must appear in the GROUP BY clause or be used in an > aggregate function > SQL state: 42803 Oops that what I get for trying air code :( This works instead: SELECT D1.*

Re: [SQL] Finding sequential records

2008-09-26 Thread Oliveiros Cristina
Howdy, Steve. SELECT id FROM dummy a NATURAL JOIN ( SELECT fkey_id,name FROM dummy GROUP BY fkey_id,name HAVING COUNT(*) > 1 AND SUM(id) = (MAX(id) + MIN(id)) * (MAX(id) - MIN(id) + 1) / 2 ) b ORDER BY id; The GROUP BY clause is to associate records that have the same fkey_id and name The COUNT(

Re: [SQL] Finding sequential records

2008-09-26 Thread Steve Midgley
Wow. Thanks to both Richard and Oliveiros. Out of the box Oliveiros' solution does what I want but I don't understand why! SELECT id FROM dummy a NATURAL JOIN ( SELECT fkey_id,name FROM dummy GROUP BY fkey_id,name HAVING COUNT(*) > 1 AND SUM(id) = (MAX(id) + MIN(id)) * (MAX(id) - MIN(id) +

Re: [SQL] Finding sequential records

2008-09-26 Thread Richard Broersma
oops I noticed I forgot the having clause: > SELECT id > FROM Dummy > GROUP BY name, fkey_id Having count(*) > 1; > SELECT A.* > FROM ( SELECT ID > FROM Dummy > GROUP BY name, fkey_id HAVING count(*) > 1 ) AS A > INNER JOIN Dummy AS D >

Re: [SQL] Problem with pg_connect() in PHP

2008-09-26 Thread Lennin Caro
--- On Fri, 9/26/08, Edward W. Rouse <[EMAIL PROTECTED]> wrote: > From: Edward W. Rouse <[EMAIL PROTECTED]> > Subject: Re: [SQL] Problem with pg_connect() in PHP > To: "'pgsql-sql'" > Date: Friday, September 26, 2008, 5:23 PM > Can I assume the missing ‘.”’ From the end of > PG_PASSWORD is a c

Re: [SQL] Problem with pg_connect() in PHP

2008-09-26 Thread ries van Twisk
On Sep 26, 2008, at 12:23 PM, Edward W. Rouse wrote: Can I assume the missing ‘.”’ From the end of PG_PASSWORD is a cut and paste error? Edward W. Rouse From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] ] On Behalf Of James Kitambara Sent: Friday, September 26, 2008 1:22 AM To: pgsql-sql

Re: [SQL] Finding sequential records

2008-09-26 Thread Oliveiros Cristina
Can this be what you need? Best, Oliveiros SELECT id FROM dummy a NATURAL JOIN ( SELECT fkey_id,name FROM dummy GROUP BY fkey_id,name HAVING COUNT(*) > 1 AND SUM(id) = (MAX(id) + MIN(id)) * (MAX(id) - MIN(id) + 1) / 2 ) b ORDER BY id; - Original Message - From: "Steve Midgley" <[E

Re: [SQL] Finding sequential records

2008-09-26 Thread Richard Broersma
On Fri, Sep 26, 2008 at 10:39 AM, Steve Midgley <[EMAIL PROTECTED]> wrote: > drop table if exists dummy; > create table dummy ( > id integer primary key, > name varchar(255), > fkey_id integer > ) > ; > The system should return > > 502163 > 502164 > 502170 > 502171 --first get all of the dup

[SQL] Finding sequential records

2008-09-26 Thread Steve Midgley
Hi, I've been kicking this around today and I can't think of a way to solve my problem in "pure SQL" (i.e. I can only do it with a looping/cursor-type solution and some variables). Given a table with this DDL/data script: drop table if exists dummy; create table dummy ( id integer primary

Re: [SQL] Problem with pg_connect() in PHP

2008-09-26 Thread Edward W. Rouse
Can I assume the missing ‘.”’ From the end of PG_PASSWORD is a cut and paste error? Edward W. Rouse From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of James Kitambara Sent: Friday, September 26, 2008 1:22 AM To: pgsql-sql Cc: Kenichiro Arakaki; Ken Arakaki Subject: [SQL] Proble

Re: [SQL] pg_dump in windows

2008-09-26 Thread James Kitambara
  Hello Ramasubramanian,   You don't have to worry about the password. You need to enter the password of the person doing the backup. One the password is provided the backup is executed.   I think that anyone executing the pg_dump must be a Super user.   Best Regards,   James Kitambara.