Re: [SQL] select column by position

2004-09-24 Thread Chester Kustarz
On Fri, 24 Sep 2004, Jennifer Lee wrote: > Is there a way to select a column in a table by its position rather than > the field name? If I understand correctly column position in a table is > fixed. I've not been able to find anything in the archives or docs to > indicate that it's possible to sele

Re: [SQL] JOIN performance

2004-09-20 Thread Chester Kustarz
On Mon, 20 Sep 2004, Dean Gibson (DB Administrator) wrote: > Okay, now for my big question: I searched high and low for a function that > would return the minimum of two dates, and found none. Now you come up > with "date_smaller", which works fine (as does "date_larger"), but where > are those d

Re: [SQL] COUNT(*) to find records which have a certain number of

2004-09-20 Thread Chester Kustarz
On Mon, 20 Sep 2004, T E Schmitz wrote: > I was feeling a bit guilty about posting such a trivial question. I can > cobble together some straightforward SQL but I could really do with a > source of more complex SQL examples. > If you know of any links - that would great and save the list from more

[SQL] move forward 0 from foo;

2004-03-23 Thread Chester Kustarz
I expected "MOVE FORWARD 0 FROM foo;" to always return 0, but I have found this not to be the case. Could anybody comment whether this is expected: mow=# begin; BEGIN mow=# create table a (a integer); CREATE TABLE mow=# insert into a values ( 1 ); INSERT 1823482 1 mow=# insert into a values ( 1 );

Re: [SQL] Question about isolation

2004-01-28 Thread Chester Kustarz
On Wed, 28 Jan 2004, Chester Kustarz wrote: > On Wed, 28 Jan 2004, Samuel Tardieu wrote: > > If in a transaction I call an embedded function in Pl/PgSQL, in which > > I have: > > > > delete from t where condition; > > for e in select distin

Re: [SQL] Question about isolation

2004-01-28 Thread Chester Kustarz
On Wed, 28 Jan 2004, Samuel Tardieu wrote: > If in a transaction I call an embedded function in Pl/PgSQL, in which > I have: > > delete from t where condition; > for e in select distinct on (f) * from t where ... loop > ... > end loop; > > Do I have the guarantee that, in any event, rows

Re: [SQL] increment int value in subset of rows?

2003-11-24 Thread Chester Kustarz
here is a work-a-round: # create table t (a int, primary key (a)); NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index 't_pkey' for table 't' CREATE # insert into t values (1); # insert into t values (1); ERROR: Cannot insert a duplicate key into unique index t_pkey # insert into t val

Re: [SQL] Quota query with decent performance?

2003-11-11 Thread Chester Kustarz
maybe: select * from person where age <= (select age from person order by age limit 1 offset 2); 7.20 msec assuming it does what you want. On Tue, 11 Nov 2003, Troels Arvin wrote: > An example of a quota query could be to get the top-3 youngest people from > a collection of people. The complica

Re: [SQL] transaction management in plpgsql functions

2003-11-09 Thread Chester Kustarz
http://www.postgresql.org/docs/7.2/interactive/plpgsql-structure.html "It is important not to confuse the use of BEGIN/END for grouping statements in PL/pgSQL with the database commands for transaction control. PL/pgSQL's BEGIN/END are only for grouping; they do not start or end a transaction. F