Fwd: Re: [SQL] sql basic question

2012-12-28 Thread Andreas Kretschmer
sorry, only a private replay and not to the list -- Ursprüngliche Nachricht -- Von: Andreas Kretschmer An: Antonio Parrotta Datum: 28. Dezember 2012 um 15:19 Betreff: Re: [SQL] sql basic question Hi, your question was: "What I want to achieve is a result table with min an

Re: [SQL] sql basic question

2012-12-28 Thread Andreas Kretschmer
gt; 12 | 23434 | 0.88764543364566 |0 *M > 33 | 23434 | 0.23235478697988 |1 *m/M > 14 | 129007 | 0.63454675634756 |0 *m > 19 | 129007 | 0.97897897897654 |0 *M > 13 | 129007 | 0.22345364656788 | 1 *m > 11 | 129007 | 0.867878

Re: [SQL] Help with a select statement design

2012-12-28 Thread Andreas Kretschmer
JORGE MALDONADO hat am 24. Dezember 2012 um 17:30 geschrieben: > I have a record with the following fields: > > id1, id2, id3, id4, price1, price2, price3, price4 > > I would like to write a SELECT statement in order to get 4 records: > > id, price (record that comes from id1 and price 1) > id,

Re: [SQL] How to reject overlapping timespans?

2013-02-17 Thread Andreas Kretschmer
Andreas hat am 17. Februar 2013 um 18:02 geschrieben: > Hi, > > I need to store data that has a valid timespan with start and enddate. > > objects ( id, name, ... ) > object_data ( object_id referencs objects(id), startdate, enddate, ... ) > > nothing special, yet > > How can I have PG reject a

Re: [SQL] Primary DB stuck becuase of unavailable standby (synchronized streaming) - please help

2013-04-18 Thread Andreas Kretschmer
Sofer, Yuval wrote: > Hi, > > > > I am using Postgres DB with stand by database, configured with streaming in > synchronized mode (each commit on primary DB waits for commit on secondary > DB). > > > > Sometimes we suffer from network issues and as consequences, secondary machine > is no

Re: [SQL]

2013-10-08 Thread Andreas Kretschmer
Kaleeswaran Velu wrote: > Hi Team, > I am using PostgreSQL 9.2.3 in Windows platform. I have created two databases > in it. Now I want to refer the tables across the databases. Meaning would like > to create Database link. Can anyone guide me on how to create a DB link? You can use db_link, see

Re: [SQL] Mac Address

2006-09-03 Thread Andreas Kretschmer
Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> schrieb: > Hi list, > > It is possible to retrieve the MAC Address of a computer using a Postgresql > function like others: In the same subnet? Then you can use untrusted languages such as plperlu or plsh to retrieve the MAC for a IP. (arp -a ip)

Re: [SQL] Substitute a Character

2006-09-06 Thread Andreas Kretschmer
Judith <[EMAIL PROTECTED]> schrieb: > Hello everybody!! I have a field type text with folios like this: > A98526 > > but I want to change de A for a 0 like this: 098526, exists a way to do > this in a query??? Perhaps something like this: test=# select regexp_replace('A98526', '

Re: [SQL] [GENERAL] How to split a table?

2006-10-17 Thread Andreas Kretschmer
Felix Zhang <[EMAIL PROTECTED]> schrieb: > Hi, > > I want to split a table to 2 small tables. The 1st one contains 60% records > which are randomly selected from the source table. > How to do it? Why do you want to do this? Andreas -- Really, I'm not out to destroy Microsoft. That will just

Re: [SQL] [GENERAL] Any documatation about porting from Oracle to PostgreSQL

2006-10-17 Thread Andreas Kretschmer
Felix Zhang <[EMAIL PROTECTED]> schrieb: > Hi all, > > I'm a newbie of PostgreSQL. I'm searching materials about porting from Oracle > to PostgreSQL. > Anyone can share with me some good documatations? http://techdocs.postgresql.org/#convertfrom Andreas -- Really, I'm not out to destroy Micr

Re: [SQL] drop a check

2006-11-13 Thread Andreas Kretschmer
ivan marchesini <[EMAIL PROTECTED]> schrieb: > Dear all... > I have created a check constraint without giving it a name.. > now I have a check named "$25" in my table that I need to drop or > modify!!! > How can I do??? Can you see the name with \d within psql? An example: test=# create table

Re: [SQL] drop a check

2006-11-13 Thread Andreas Kretschmer
ivan marchesini <[EMAIL PROTECTED]> schrieb: > . > or it depend on the fact I'm using postgres 7.4.13 > many thanks... Maybe, the information-schema can be different in different versions. Andreas -- Really, I'm not out to destroy Microsoft. That will just be a completely unintentional sid

Re: [SQL] select into

2006-11-22 Thread Andreas Kretschmer
Richard Broersma Jr <[EMAIL PROTECTED]> schrieb: > > Hi guys, > > > >Am new to sql scripting so this might be a stupid question. Am getting > > an error while trying > > to do the following > > > > SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id; > > > > where svc_data_

Re: [SQL] select into

2006-11-24 Thread Andreas Kretschmer
Adrian Klaver <[EMAIL PROTECTED]> schrieb: > On Thursday 23 November 2006 08:45 pm, Tom Lane wrote: > > Mulham freshcode <[EMAIL PROTECTED]> writes: > > > execute sql_str1 into svc_data_rec ; > > > > > > svc_data_rec is a RECORD, which is supposed to be dynamic. > > > > This should work --- in PG

Re: [SQL] consistent random order

2006-11-29 Thread Andreas Kretschmer
Jeff Herrin <[EMAIL PROTECTED]> schrieb: > I am returning results ordered randomly using 'order by random()'. My issue > has > to do with page numbers in our web application. When I hit the 2nd page and > retrieve results with an offset, ordering by random() isn't really what I want > since I wil

Re: [SQL] Changing point for commas and commas for point

2007-01-21 Thread Andreas Kretschmer
Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> schrieb: > Hi list, > > Here in my country (Brazil) we have the decimal simbol as ' , ' (commas) and > thousand separator as ' . ' (point) > > Here my sql uses: to_char(sum(My_column), '0D00') > > Is there any way to make this happens ? I t

Re: [SQL] [ADMIN] Deadlock on transaction

2007-02-12 Thread Andreas Kretschmer
Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> schrieb: > I mean really deadlock. Other transactions can't access the database until the > main transaction is complete. A question: That's not true. > > PostgreSQL doesn't permit multiple transactions concurrently ? Why not? Show us a complete

Re: [SQL] sub-limiting a query

2007-02-17 Thread Andreas Kretschmer
Louis-David Mitterrand <[EMAIL PROTECTED]> schrieb: > ballet,etc.) and I am looking for a select that can return the 10 last > entered shows AND at most 2 of each type. Is that possible in one query? A similar question i found in the archive and there are a couple of answers: (for the second par

Re: [SQL] Inc

2007-03-06 Thread Andreas Kretschmer
Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> schrieb: > Thank you but I must inc an specific row. How to do that ? Read the answer again. Please, no silly TOFU (german synonym for text above, fullquote below). > >> For example. I have a table with a field that on each update it > >> incremen

Re: [SQL] Inc

2007-03-06 Thread Andreas Kretschmer
Richard Broersma Jr <[EMAIL PROTECTED]> schrieb: > --- Ezequias Rodrigues da Rocha <[EMAIL PROTECTED]> wrote: > > > Thank you but I must inc an specific row. How to do that ? > > > > Does, > > UPDATE your_table > SET your_row = your_row +1 > WHERE your_pkey = ; > > not do what you need? I th

Re: [SQL] how to use a date range in a join

2007-03-12 Thread Andreas Kretschmer
chester c young <[EMAIL PROTECTED]> schrieb: > trying to do something like > > select d.day, >c.name > from [dates between day1 and day2] d > left join c.some_table; > > but cannot figure out what to put into the brackets. Perhaps something like this: test=# select curre

Re: [SQL] ordering by multiple columns

2007-03-14 Thread Andreas Kretschmer
Pablo Barrón <[EMAIL PROTECTED]> schrieb: > > Hi! > > I'm trying to order a list in which the first parameter to order is a > specific > field, and the second should vary depending on a specific condition. More > explicit, I would like to do something like: > > - ORDER BY a.column1, [b.colu

Re: [SQL] union with count?

2007-03-28 Thread Andreas Kretschmer
Gerardo Herzig <[EMAIL PROTECTED]> schrieb: > Thanks! But now i have another problem related with count(): > > select page_id, word, word_position, count(page_id) from (select * from > search_word('word1', 'table1') union search_word('word2', 'table2')) foo > group by page_id; > > and gives me

Re: [SQL] plpgsql function question

2007-04-03 Thread Andreas Kretschmer
Karthikeyan Sundaram <[EMAIL PROTECTED]> schrieb: > > Hi, > > I am having a requirement here. > > 1) I need to write a plpgsql function where it takes the input > parameter of a structure of a table. Because? To build this table? You can pass an ascii-text

Re: [SQL] show index from [table]

2007-06-08 Thread Andreas Kretschmer
Stefan Zweig <[EMAIL PROTECTED]> schrieb: > hi list, > > currently i am switching from mysql to pgsql, so i am a bit new to > postgres' syntax. You are welcome. > > at the moment i am looking in postgres for something which is similar > to SHOW INDEX FROM [table] in mysql. unfortunately i coul

Re: [SQL] joining a table whose name is stored in the primary record

2007-06-17 Thread Andreas Kretschmer
John Gunther <[EMAIL PROTECTED]> schrieb: > I've tried everything I can think of here to join records when the join > table varies and is named in the primary record, but to no avail. Here's an > example with all non-essentials stripped out. > > I have 3 tables: > > create table zip ( > id se

Re: [SQL] Counting all rows

2007-06-23 Thread Andreas Kretschmer
Stefan Arentz <[EMAIL PROTECTED]> schrieb: > I need to get statistics from a bunch of tables. Simply the number of > records in them. > > The query plan looks like this: > > => explain select count(id) from stuff; > QUERY PLAN > ---

Re: [SQL] Format intervall as hours/minutes etc

2007-09-16 Thread Andreas Kretschmer
Andreas Joseph Krogh <[EMAIL PROTECTED]> schrieb: > Hi all. Any hint on how to format this interval as number of hour/seconds etc? > select age('2007-09-22 17:00'::timestamp, '2000-02-20 18:00'::timestamp); > age > --- > 7 years 7 mons 1 day 23:00:00 You

Re: [SQL] What SQL is running against my DB?

2007-10-04 Thread Andreas Kretschmer
Tore Lukashaugen <[EMAIL PROTECTED]> schrieb: > Hello all, > > I have an application running against my postgres 8.2 database (on Windows > Vista) for which I do not have access to the source code. > > I would like to know what SQL statements are being executed by the > application. Is there a

Re: [PERFORM] [SQL] two queryes in a single tablescan

2007-10-20 Thread Andreas Kretschmer
Markus Schaber <[EMAIL PROTECTED]> schrieb: > > is there any way to get both results in a single query, > > eventually through stored procedure? > > The retrieved [count(*),A] ; [count(*),B)] data couldnt fit > > on a single table, of course. > > > > The main goal would be to get multiple results

Re: [SQL] Removing whitespace using regexp_replace

2007-10-28 Thread Andreas Kretschmer
Thomas Kellerer <[EMAIL PROTECTED]> schrieb: > Hi, > > I have a column with the datatype "text" that may contain leading > whitespace (tabs, spaces newlines, ...) and I would like to remove them all > (ideally leading and trailing). You can use trim() for that: select 'x' || trim(both '\t' fr

Re: [SQL] Removing whitespace using regexp_replace

2007-10-28 Thread Andreas Kretschmer
Thomas Kellerer <[EMAIL PROTECTED]> schrieb: > Andreas Kretschmer wrote on 28.10.2007 12:42: > >>I have a column with the datatype "text" that may contain leading > >>whitespace (tabs, spaces newlines, ...) and I would like to remove them > >>all

Re: [SQL] execute system command from storage procedure

2007-12-06 Thread Andreas Kretschmer
Sabin Coanda <[EMAIL PROTECTED]> schrieb: > Hi there, > > Is it possible to execute a system command from a function ? (e.g. bash ) Yes, of course, but you need an untrusted language like pl/perlU oder plsh. http://plsh.projects.postgresql.org/ Andreas -- Really, I'm not out to destroy Micros

Re: [SQL] INSERT INTO relational tables

2007-12-07 Thread Andreas Kretschmer
Stefan Scheidegger <[EMAIL PROTECTED]> schrieb: > An example to explain my Problem: Lets say I have a table containing > information about the customer (name, address, ...) and about his > order (pieces, product-name, price). Because one customer can order > several products I split the table into

Re: [SQL] Concatenation through SQL

2007-12-21 Thread Andreas Kretschmer
Philippe Lang <[EMAIL PROTECTED]> schrieb: 2 ways: * You can use something like this: test=*# select * from a; id | val +- 1 | foo 2 | bar (2 rows) test=*# select array_to_string(array(select val from a), ', '); array_to_string - foo, bar (1 row) * comma-aggrega

Re: [SQL] merge timestamps to intervals

2008-05-12 Thread Andreas Kretschmer
Patrick Scharrenberg <[EMAIL PROTECTED]> schrieb: > Hi! > > I have a table where I repeatingly log the status of some service, which > looks something like this: > > < timestamp, status > > > > I'd like to merge this information to intervals where the service was up > or down. > >

Re: [SQL] using calculated column in where-clause

2008-06-17 Thread Andreas Kretschmer
Patrick Scharrenberg <[EMAIL PROTECTED]> schrieb: > Something like this > select a, b , a*b as c from ta where c=2; > > But postgresql complains, that column "c" does not exist. > > Do I have to repeat the calculation (which might be even more complex yes. Andreas -- Really, I'm not out to de

Re: [SQL] Select function with set return type

2008-08-18 Thread Andreas Kretschmer
Nacef LABIDI <[EMAIL PROTECTED]> schrieb: > Hi all, > > I am writing some functions with retrun type as a SETOF of a datatype that I > have defined. How can I test them with a select statement. > Doing select my_function(); return set valued function called in context that > cannot accept a set

Re: [SQL] EXECUTE query INTO problem

2008-11-25 Thread Andreas Kretschmer
Tk421 <[EMAIL PROTECTED]> schrieb: >I've got a problem with a function: It receives two parameters, the > first, the table name, and the second, a where condition. The function > looks like this: > >DECLARE > cod bigint; > query TEXT; > >BEGIN > query = 'SELECT co

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Andreas Kretschmer
Louis-David Mitterrand <[EMAIL PROTECTED]> schrieb: > > But if I append this > >order by pt.type_fr = 'comédien'; > > I get this error: > > ERROR: column "pt.type_fr" must appear in the GROUP BY clause or be > used in an aggregate function > > It seems I am using pt.type_fr in

Re: [SQL] adding "order by" to a "group by" query

2008-12-06 Thread Andreas Kretschmer
Scott Marlowe <[EMAIL PROTECTED]> schrieb: > >> You can use a subquery like my example: > >> > >> test=*# select i, comma(t) from (select distinct i,t from foo) bar group > >> by i; > >> i | comma > >> ---+- > >> 1 | a, b, c > >> (1 row) > >> > >> Time: 0.554 ms > >> test=*# select i, c

Re: [SQL] Seeking for the fore-part of the key

2009-01-11 Thread Andreas Kretschmer
Havasvölgyi Ottó schrieb: > Hi, > > Let's assume I have a table (called tbl) with a column 'name' and an index on > it. > How to optimally find records whose name column begins with - say - "Pre"? > I know it can be done with LIKE (WHERE name LIKE 'Pre%'), but will this use > the > index mentio

Re: [SQL] counts of groupings by date year-month

2009-02-27 Thread Andreas Kretschmer
Carol Cheung wrote: > Hi, > I have a table called temp > > access_date | active | status > -++ > 2009-02-01 | t | 15 > 2009-02-01 | f | 16 > 2009-02-02 | f | 17 > 2009-02-01 | t | 17 > 2009-02-02 | f | 21 > 2009-

Re: [SQL] how to set the value to the column

2009-04-16 Thread Andreas Kretschmer
DM wrote: > Hi All, > > I have a table test with columns name and value > > test table > name > value > > It has around 500 rows. > > I added a new column id to the table, > > Table test > id, > name, > value > > I am not sure how to insert numbers to my column id (1-500). You can cr

<    1   2