Re: [SQL] Extracting data by months

2000-08-03 Thread Daniel Kalchev
Actually, PostgreSQL has specific function for this purpose. The query would be: SELECT * FROM table WHERE date_part('month', date_field) = '8'; (example to select month 8) If you use date_trunc, the selection will be by month/year - that is, date_trunc('month', date_field) will always result

[SQL] Recursive SQL

2000-08-03 Thread database
Dear all, Is postgresql supporting recursive sql? If no, how can my sql to change for recursive function ( on 4 or 5 levels are needed ) ? Many thanks! Best regards, Boris

Re: [SQL] PL/pgSQL evaluation order

2000-08-03 Thread Mark Volpe
Doesn't seem like a bad idea. I did find a better workaround, though - cond:=TG_OP=''INSERT''; IF cond=FALSE THEN cond:=NEW.ip!=OLD.ip; END IF; IF cond=TRUE ... so it won't kill me. Anyway, I've been totally impressed with the 7.0 release. I'm building the EPA IP address registration sys

Re: [SQL] A question about indexes...

2000-08-03 Thread Tom Lane
Alexaki Sofia <[EMAIL PROTECTED]> writes: > I can either define the field id as a Primary Key or create an Btree index > on it. What is more effient?? > From my test I see that creating Btree index is a bit faster!!. I think you're seeing things. Declaring a field primary key creates a btre

Re: [SQL] Extracting data by months

2000-08-03 Thread John McKown
This might seem rather silly, but could you simply do something like: select * from database where date_field >= '01/01/2000'::date and date_field < '02/01/2000'::date; Of course, if date_field could contain many different years, then this would not get you the result you wanted.

[SQL] A question about indexes...

2000-08-03 Thread Alexaki Sofia
Hello, I have the following tables in my db Painter (id integer, uri varchar(256)) and paints (id1 integer, id2 integer) I want to optimize the question select id from Painter where uri = 'x'; What kind of index (Btree or Hash) is more efficient to create on field uri since it'

[SQL] PL/pgSQL evaluation order

2000-08-03 Thread Mark Volpe
Hi, I have trigger function with the statement: IF TG_OP=''INSERT'' OR NEW.ip!=OLD.ip THEN expecting the TG_OP=''INSERT'' to be evaluated first, and if true, proceed with the body. But it gets evaluated as the result of an INSERT statement, I get a (rather strangly worded) error: ERROR: record

[SQL] Re: PL/pgSQL

2000-08-03 Thread Mark Volpe
Oh yeah, I'm using v7.0 Mark

Re: [SQL] SQL (table transposition)

2000-08-03 Thread Mark Volpe
Hope you like black magic :) SELECT IND AS T1_INDEX, MIN(CASE WHEN KEY=1 THEN VALUE ELSE NULL END) AS KEY1VAL, MIN(CASE WHEN KEY=2 THEN VALUE ELSE NULL END) AS KEY2VAL, MIN(CASE WHEN KEY=3 THEN VALUE ELSE NULL END) AS KEY3VAL FROM T2 GROUP BY IND ORDER BY IND; Mark [EMAIL PROTECTED] wrote: > >

[SQL] SQL (table transposition)

2000-08-03 Thread Dana . Reed
Is there any way to get table T3 (below) from T1 and T2 using SQL (select, view, etc)? T3 is basically all INDEX values from T1 matched to IND from T2 with the corresponding KEY/VALUE pairs transposed from rows to columns. --- |INDEX| (T1) --- | 1 | | 2 | | 3 | ---

Re: [SQL] a question about dates and timestamp

2000-08-03 Thread Tom Lane
Ange Michel POZZO <[EMAIL PROTECTED]> writes: > select datetime(abstime( floor (value) )); > select datetime(abstime( int4 (value) )); > select datetime(abstime( numeric_int4 (value) )); > in all case : > ERROR: pg_atoi: error in "952969611.00": can't parse ".00" That was fixed in Janu

Re: [SQL] What is happening?

2000-08-03 Thread Tom Lane
Carolyn Lu Wong <[EMAIL PROTECTED]> writes: > I was trying to dump data, drop then recreate table, and import data > back to the table. There were errors during the process and the > transaction was not committed. > ERROR: mdopen: couldn't open accounts: No such file or directory. Rolling back a

[SQL] Extracting data by months

2000-08-03 Thread Antti Linno
Lo. I'm in dire need of knowledge, how to extract data by month. Monthday and year arent' important, those I can't give from perl script, but what I do give to postgres are the numbers of the months. Date field is in timestamp. I thought about date_trunc, but I can't think of, how to get data wi

Re: [SQL] What is happening?

2000-08-03 Thread The Hermit Hacker
On Thu, 3 Aug 2000, Carolyn Lu Wong wrote: > I was trying to dump data, drop then recreate table, and import data > back to the table. There were errors during the process and the > transaction was not committed. > > The table is there when I do '\d' and the table definition is there. > However,

Re: [SQL] a question about dates and timestamp

2000-08-03 Thread Karel Zak
On Thu, 3 Aug 2000, Ange Michel POZZO wrote: > Le jeu, 03 aoű 2000, Karel Zak a écrit : > > > my question is how can i convert the numeric or the int4 value to > > > a date value? > > > > > > test=# select abstime(965293003); > > abstime > > > > 2000-08-03 10

Re: [SQL] a question about dates and timestamp

2000-08-03 Thread Ange Michel POZZO
Le jeu, 03 aoû 2000, Karel Zak a écrit : > > my question is how can i convert the numeric or the int4 value to > > a date value? > > > test=# select abstime(965293003); > abstime > > 2000-08-03 10:56:43+02 > (1 row) > > Ka

Re: [SQL] a question about dates and timestamp

2000-08-03 Thread Karel Zak
> my question is how can i convert the numeric or the int4 value to > a date value? test=# select abstime(965293003); abstime 2000-08-03 10:56:43+02 (1 row) Karel

[SQL] a question about dates and timestamp

2000-08-03 Thread Ange Michel POZZO
hi all i have a table like this id_message int4 not null default nextval ( ... id_abonneint4 texte_message varchar() not null date_message numeric not null the default size of numeric is 30.6 another table : id_message int4 id_abonneint4 text_message text date