[SQL] Is there a solution for "SELECT OR INSERT"

2010-11-28 Thread Stefan Becker
given a simply table table like this: create table MyTabl (id serial, lname varchar, primary key (id) ) I am trying to return the Primary-Key for a given row regardless of the wanted row already being in the table. using something like: select coalesce ( (select id from MyTabl where lnam

Re: [SQL] pg_clog (?) problem with VACUMM

2007-11-27 Thread Stefan Becker
I found out MUCH later found out - I could no longer vacuum the Database. I restored the missing files from a backup and everything was okay again, after a vacuum of the database the system cleaned out the older pg_log/ files on its own. I hope you get things fixed! My

Re: [SQL] ROW_NUMBER alias

2007-05-06 Thread Stefan Becker
I might be told off by some better SQL-User here on the list - still here is my 2 Cents worth > I needed ROW_NUMBER() in PostGresql and I did find the 'temporary sequence' > method as a workaround and i think it at least gets the job done relatively you use: > CREATE TEMP SEQUENCE rownum

Re: [SQL] Selecting exactly one row for each column value

2007-03-06 Thread Stefan Becker
Am Dienstag, 6. März 2007 16:03 schrieb Florian Weimer: > a | b | c > ---+---+--- > 5 | 6 | 7 > 2 | 3 | 4 > 1 | 2 | 3 Hi, couldn't you accomplish this by: select distinct on (a) * from tablename order by a; here: create table tab (a int,b int,c int); insert into tab values (1,2,3); insert

[SQL] how do I to generate a sequence Range or Set of integer constants

2007-02-23 Thread Stefan Becker
d,x.A,x.B,x.C, from MyDataTable x left outer join ( select MissingValues from "1 to 1000" of integers ) IntSeq on MissingValues=x.UniqIntId I'm hoping that someone has done this and might be able to point to some function or methode to do this Thanks, Stefan Becker -- email: [

Re: [SQL] regarding join

2006-03-25 Thread Stefan Becker
given this. create table AA (id serial,name varchar(15)); create table BB (id serial,name varchar(15)); insert into AA (name) values ('1243f'); insert into AA (name) values ('asdfef'); insert into AA (name) values ('fdbsfd'); insert into AA (nam

Re: [SQL] group by function, make SQL cleaner?

2006-03-18 Thread Stefan Becker
this should work, # SELECT date_trunc('day',endtime),count(*) FROM eg_event where endtime >= '2006-02-01' and endtime < '2006-03-01' GROUP BY 1 ORDER BY 1; best regards, Stefan Am Donnerstag, 16. März 2006 06:18 schrieb Bryce Nesbitt: > I've got a working query: > > stage=# SELEC

Re: [SQL] customising serial type

2005-06-27 Thread Stefan Becker
Am Dienstag, 21. Juni 2005 12:01 schrieben Sie: > hi,in a table with a serial datatype, how do i get the sequence to start at > a specific number like 10? Use START in the create sequence statement. # create sequence seq_xeingang increment 1 start 1000; ; CREATE TABLE xeingang ( id