Re: [SQL] Aggregates with NaN values

2008-12-05 Thread Sean Davis
On Fri, Dec 5, 2008 at 1:51 PM, Mark Roberts <[EMAIL PROTECTED]> wrote: > > On Thu, 2008-12-04 at 13:01 -0500, Sean Davis wrote: >> I am happy to see NaN and infinity handled in input. I would now like >> to compute aggregates (avg, min, max, etc) on columns with NaN

[SQL] Aggregates with NaN values

2008-12-04 Thread Sean Davis
I am happy to see NaN and infinity handled in input. I would now like to compute aggregates (avg, min, max, etc) on columns with NaN values in them. The standard behavior (it appears) is to have the aggregate return NaN if the data contain one-or-more NaN values. I am used to using coalesce with

[SQL] Reporting functions (OLAP)

2007-08-30 Thread Sean Davis
I am looking for reporting extensions such as windowing, ranking, leads/lags, etc. for postgresql. A quick google search turned up some "working on it" type results, but I was wondering if anything actually existed up to this point? Thanks, Sean ---(end of broadcast)-

[SQL] Re: [NOVICE] Install two different versions of postgres which should run in parallel

2007-08-10 Thread Sean Davis
Loredana Curugiu wrote: > Hi all, > > I need to have two different vesions of postgres running in parallel on > different ports. Does anyone knows how to install two different versions > of postgres (7.4.5 and 8.2.4) on the same computer? I am using Linux > operating system. You can install from

Re: [SQL] [NOVICE] JOIN

2007-06-05 Thread Sean Davis
Loredana Curugiu wrote: > Hi everybody, > > I have the following table: > > count | theme | receiver| date > | dates >| > ---+---+--

Re: [SQL] RETURNS SETOF primitive returns results in parentheses

2005-10-26 Thread Sean Davis
On 10/26/05 8:38 AM, "Mario Splivalo" <[EMAIL PROTECTED]> wrote: > Consider this function: > > CREATE OR REPLACE FUNCTION php_get_subfield_data_repeating(int4, > "varchar") > RETURNS SETOF "varchar" AS > $BODY$ > DECLARE > aRecordID ALIAS FOR $1; > aSubFieldId ALIAS FOR $2; > > returnValue recor

Re: [SQL] SETOF RECORD RETURN VALUE

2005-10-26 Thread Sean Davis
On 10/26/05 6:34 AM, "Christian Paul B. Cosinas" <[EMAIL PROTECTED]> wrote: > Hi I am having some problem with function that returns SETOF RECORD > > Here is my function: > > CREATE OR REPLACE FUNCTION test_record(text) > RETURNS SETOF RECORD AS > $BODY$ > > > DECLARE > p_table_name ALIAS FOR

Re: [SQL] question re. count, group by, and having

2005-10-11 Thread Sean Davis
On 10/11/05 8:50 AM, "Rick Schumeyer" <[EMAIL PROTECTED]> wrote: > The following query returns an error ("column c does not exist") in pg 8.0.3: > > > > (The column 'state' is the two letter abbreviation for a US state) > > > > -- get the number of rows for each state; list in descending ord

Re: [SQL] RULES on SELECT with JDBC/perlDBI from other RDBMS

2005-10-07 Thread Sean Davis
On 10/6/05 9:07 PM, "Bath, David" <[EMAIL PROTECTED]> wrote: > Folks, > > I'm looking at using pg to be the main platform for integrating info > from other RDBMS products (particularly Oracle) as pg seems to be > the most flexible RDBMS around. > > Disregarding writing to foreign products, query

[SQL] R-tree and start/end queries

2005-09-21 Thread Sean Davis
I have a table like: Create table gf ( pkserial, start int, end int, gfvarchar ); I want to do queries along the lines of: "find all gf that overlap with (1,2)" or "find all gf that overlap with each other" And others. I have read over the documentation, but I

Re: [SQL] table listing queries

2005-08-25 Thread Sean Davis
On 8/25/05 7:13 AM, "Daniel Silverstone" <[EMAIL PROTECTED]> wrote: > Hi, > > I know that questions like this have been asked in the past, but I can > find no definitive answer to one particular part of my problem... > > Namely, in MySQL I can say: "SHOW TABLES FROM 'dbname'" to list tables > in

Re: [SQL] How to join several selects

2005-08-24 Thread Sean Davis
On 8/24/05 9:46 AM, "Josep Sanmartí" <[EMAIL PROTECTED]> wrote: > Hello, > I have a 'big' problem: > I have the following table users(name, start_time, end_time), a new row > is set whenever a user logs into a server. I want to know how many > users have logged in EVERYDAY between 2 different dat

Re: [SQL] SQL Newbie

2005-08-12 Thread Sean Davis
On 8/12/05 11:09 AM, "Lane Van Ingen" <[EMAIL PROTECTED]> wrote: > It seems to me that I should be able to do this, but after 5 hrs of trying, > I > can't figure this one out. > > I could do this in two queries, but seems like I should be able to do this > in > one. What I am trying to do: > Find

Re: [SQL] How to connect ORACLE database from Postgres function

2005-08-01 Thread Sean Davis
Title: Re: [SQL] How to connect ORACLE database from Postgres function using plpgsql/pltclu? On 8/1/05 6:35 AM, "Dawid Kuroczko" <[EMAIL PROTECTED]> wrote: On 8/1/05, Dinesh Pandey <[EMAIL PROTECTED]> wrote: > Is there any way to connect ORACLE database from Postgres function using > plpgsql/

Re: [SQL] How can I simply substatue a value in a query?

2005-06-27 Thread Sean Davis
   - Original Message - From: Roy Souther To: pgsql-sql@postgresql.org Sent: Monday, June 27, 2005 1:16 PM Subject: [SQL] How can I simply substatue a value in a query? I want to do a simple substatution of a value in a query. For example I have a boolean fiel

Re: [SQL] Alias to a type

2005-06-22 Thread Sean Davis
On Jun 22, 2005, at 7:42 AM, Achilleus Mantzios wrote: O Veikko Mδkinen έγραψε στις Jun 22, 2005 : Hey, Is it possible to create a new type as an alias to a pre-defined type? I use "USERID varchar(20)" in almost every table I have I'd like to make an alias for that type eg. create typ

Re: [SQL] Does Postgresql have a similar pseudo-column "ROWNUM" as

2005-05-18 Thread Sean Davis
On May 18, 2005, at 3:52 PM, Chris Browne wrote: [EMAIL PROTECTED] (Alain) writes: Andrew Sullivan escreveu: On Thu, May 12, 2005 at 01:07:00PM -0600, [EMAIL PROTECTED] wrote: Does Postgresql have a similar pseudo-column "ROWNUM" as Oracle? If so, we can write the following query: No. What is th

Re: [SQL] Looking for a way to sum integer arrays....

2005-04-23 Thread Sean Davis
You would definitely want to look into using pl/R for this. Also, other procedure languages (perl, for example) work well with arrays so may be easier to use for this situation. As for the aggregate, I don't know how to make that more dynamic in terms of return value. Sean - Original Mess

Re: [SQL] Query about SQL in PostgreSQL

2005-04-19 Thread Sean Davis
On Apr 19, 2005, at 5:48 AM, Muhammad Nadeem Ashraf wrote: Hi, I am new user of PostGreSQL 8.0.1. While using it i faced following issue. As SQL is Case insensetive Language So the Uper or Lower cases are not significant. But while using the database there is problem. If i Create new Table with n

Re: [SQL] Function declaration

2005-04-18 Thread Sean Davis
le to pass a SQL NULL as an argument. Sean - Original Message - From: "A. Kulikov" <[EMAIL PROTECTED]> To: "Sean Davis" <[EMAIL PROTECTED]> Sent: Monday, April 18, 2005 8:44 PM Subject: Re: [SQL] Function declaration Unfortunately that is not what I am

Re: [SQL] How to add 1 hour in a date or time stamp?

2005-04-18 Thread Sean Davis
Dinesh,   The documentation is very helpful for this topic.  Typing 'add 1 hour timestamp' into the search box at:   http://www.postgresql.org/docs/8.0/interactive/index.html   yields the following page as the first hit:   http://www.postgresql.org/docs/8.0/static/functions-datetime.html   Sea

Re: [SQL] user connection over tcp

2005-04-18 Thread Sean Davis
Did you start the postmaster with -i to allow tcp connections? What is the error that you get when you try to connect? Sean - Original Message - From: "Frank Habermann" <[EMAIL PROTECTED]> To: Sent: Monday, April 18, 2005 9:31 AM Subject: [SQL] user connection over tcp hello! i have

Re: [SQL] Combining values in a column

2005-04-15 Thread Sean Davis
See below for creating aggregates: http://www.postgresql.org/docs/current/static/xaggr.html But, there is a useful function built-in, bit_and, that does what you want: http://www.postgresql.org/docs/current/static/functions- aggregate.html#FUNCTIONS-AGGREGATE-TABLE create table testint (

Re: [SQL] dynamic 'INSERT' query?

2005-04-14 Thread Sean Davis
On Apr 14, 2005, at 7:37 AM, Dinesh Pandey wrote: How can we set A1, A2 values in dynamic 'INSERT’  query?   DECLARE  _record    RECORD;  _sql VARCHAR(2000);   FOR _record IN SELECT A1, A2 FROM A LOOP   _sql := 'INSERT INTO B VALUES (:A1, :A2)’;   EXECUTE (_sql);   END LOOP;   =

Re: [SQL] Problems with Set Returning Functions (SRFs)

2005-04-11 Thread Sean Davis
On Apr 6, 2005, at 2:53 PM, Otto Blomqvist wrote: secom=# select f1, f2, f3 from testpassbyval(1, (Select number1 from test)); ERROR: more than one row returned by a subquery used as an expression This is where I fail. Am I even on the right path here ? Writing the actual parsing function will

Re: [SQL] Question on triggers and plpgsql

2005-04-08 Thread Sean Davis
On Apr 8, 2005, at 8:28 AM, John DeSoi wrote: On Apr 7, 2005, at 5:45 PM, Carlos Moreno wrote: The thing seems to work -- I had to go in a shell as user postgres and execute the command: $ createlang -d dbname plpgsql (I'm not sure I understand why that is necessary, or what implications -- positiv

Re: [SQL] Table PARTITION

2005-04-07 Thread Sean Davis
This is a totally selfish question, but IF someone has a few minutes, could he/she explain why table partitioning is such an important tool? Thanks, Sean On Apr 7, 2005, at 8:06 AM, Richard Huxton wrote: Dinesh Pandey wrote: How can we create oracle's table with partition in Postgres. (How to cr

Re: [SQL] a very big table

2005-04-03 Thread Sean Davis
- Original Message - From: "_moray" <[EMAIL PROTECTED]> To: Sent: Tuesday, March 29, 2005 12:25 PM Subject: [SQL] a very big table hullo all, I have a problem with a table containing a lot of data. referred tables "inserzionista" and "pubblicazioni" (referenced 2 times) have resp. 1909

Re: [SQL] cost of CREATE VIEW ... AS SELECT DISTINCT

2005-03-29 Thread Sean Davis
On Mar 29, 2005, at 5:07 AM, T E Schmitz wrote: Hello Scott, Scott Marlowe wrote: On Mon, 2005-03-28 at 15:43, T E Schmitz wrote: How expensive would it be to maintain the following VIEW: CREATE VIEW origin AS SELECT DISTINCT origin FROM transaktion if there is in index on transaktion.origin; the t

Re: [SQL] Self-referencing table question

2005-03-24 Thread Sean Davis
On Mar 24, 2005, at 2:37 PM, Edmund Bacon wrote: Sean Davis wrote: Nice. Thanks for doing my work for me! Yeah, well put it down to a certain amount of curiosity and a slack period at work ... I guess I will have to think about it more seriously. It could be a slight bit complicated because my

Re: [SQL] Self-referencing table question

2005-03-24 Thread Sean Davis
On Mar 24, 2005, at 1:11 PM, Edmund Bacon wrote: Sean Davis wrote: Thanks. I thought about that a bit and it seems like it is highly likely to be expensive for a single query (though I should probably try it at some point). If I do find myself reformatting results after response to user input

Re: [SQL] Self-referencing table question

2005-03-24 Thread Sean Davis
ation_pkey on correlation c (cost=0.00..9.63 rows=2 width=16) (actual time=0.024..0.025 rows=0 loops=4950) Index Cond: (("outer".from_id = c.from_id) AND ("outer".to_id = c.to_id)) Filter: (val > 0.5::double precision) Total runtime: 152.261 ms Richard

Re: [SQL] Self-referencing table question

2005-03-23 Thread Sean Davis
On Mar 22, 2005, at 7:07 PM, Sean Davis wrote: - Original Message - From: "Richard Huxton" To: "Sean Davis" <[EMAIL PROTECTED]> Cc: "PostgreSQL SQL" Sent: Tuesday, March 22, 2005 3:59 PM Subject: Re: [SQL] Self-referencing table question Sean Davis

Re: [SQL] Self-referencing table question

2005-03-22 Thread Sean Davis
- Original Message - From: "Richard Huxton" To: "Sean Davis" <[EMAIL PROTECTED]> Cc: "PostgreSQL SQL" Sent: Tuesday, March 22, 2005 3:59 PM Subject: Re: [SQL] Self-referencing table question Sean Davis wrote: I answer my own question, if only for m

Re: [SQL] Self-referencing table question

2005-03-22 Thread Sean Davis
s=100 loops=1) Sort Key: val -> Index Scan using correlation_from_id_idx on correlation (cost=0.00..557.42 rows=24624 width=13) (actual time=0.517..20.307 rows=7788 loops=1) Index Cond: (from_id = 2424) Total

[SQL] Self-referencing table question

2005-03-22 Thread Sean Davis
I have a table that looks like: Column | Type | Modifiers | Description -+--+---+- from_id | integer | not null | to_id | integer | not null | val | numeric(4,3) | | Indexes: "correlation_pkey" PRIMARY KEY, btree (

Re: [SQL] "Flattening" query result into columns

2005-03-21 Thread Sean Davis
Thomas,   You probably want a crosstab.  There is a contributed module in contrib/crosstab.  If you do a search of the postgres mailing lists, there will be several posts relating to the same issue.   Sean   - Original Message - From: Thomas Borg Salling To: pgsql-sql@p

Re: [SQL] Newbie wonder...

2005-03-13 Thread Sean Davis
Bernard, If you are simply doing a one-time convert of an old database schema to a new one, simply load the old tables into postgres and then use SQL commands to insert the data into the new tables. For a sequence on the "existing table," you can do as above and load the old table or just use c

Re: [SQL] count array in postgresql

2005-03-06 Thread Sean Davis
How about array_dims? It looks like you will still have to do a string split, but Sean - Original Message - From: "bandeng" <[EMAIL PROTECTED]> To: Sent: Sunday, March 06, 2005 9:09 PM Subject: Re: [SQL] count array in postgresql my Postgresql version is 7.4 I still cannot find c

Re: [SQL] Building a database from a flat file

2005-03-03 Thread Sean Davis
On Mar 3, 2005, at 1:37 PM, Casey T. Deccio wrote: On Thu, 2005-03-03 at 08:28 -0700, Markus Schaber wrote: - Create the new date in another schema, and then simply rename those two schemas for "switch over" This worked very well. I created another schema ("build") and populated the tables within

Re: [SQL] how to speed up these queries ?

2005-03-03 Thread Sean Davis
On Mar 3, 2005, at 8:34 AM, Dracula 007 wrote: It looks like you are going to always do a sequential scan on the tables, as you always look a the entire table(s). How often do you do the query as compared to the load on the database? If you do the query often relative to the load, could you k

Re: [SQL] Building a database from a flat file

2005-03-03 Thread Sean Davis
On Mar 2, 2005, at 7:15 PM, Casey T. Deccio wrote: A database I am currently using is built and updated periodically from a flat csv file (The situation is rather unfortunate, but that's all I have right now). The schema I use is more complex than the flat file, so I follow a process to populate

Re: [SQL] how to speed up these queries ?

2005-03-03 Thread Sean Davis
On Mar 3, 2005, at 6:05 AM, Dracula 007 wrote: Hello, I have two "large" tables - "sessions" (about 1.500.000 rows) and "actions" (about 4.000.000 rows), and the "actions" table is connected to the "sessions" (it contains a key from it). The simplified structure of these tables is sessions (

Re: [SQL] Junk queries with variables?

2005-02-28 Thread Sean Davis
- Original Message - From: "Steve Valaitis" <[EMAIL PROTECTED]> To: "KÖPFERL Robert" <[EMAIL PROTECTED]>; Sent: Thursday, February 24, 2005 12:15 PM Subject: Re: [SQL] Junk queries with variables? > In pgadmins SQL-window SQL is the 'language' of choice. Or it is rather the only langua

Re: [SQL] Software for database-visualisation

2005-02-24 Thread Sean Davis
If you mean literally visualizing the ERD, you can look at SQL::Translator (on cpan) which can draw fairly complex ERDs and output as graphics (I forget the supported formats) Sean On Feb 24, 2005, at 3:17 AM, Richard Huxton wrote: Kai Hessing wrote: Another question: Which software are you

Re: [SQL] More efficient OR

2005-02-16 Thread Sean Davis
Could 'in' or 'between' do what you want? I know that using 'in' is equivalent to what you have below. Could 'between' be more efficient--you could do explain analyze on various options to see what the actual plan would be. Sean On Feb 16, 2005, at 11:02 AM, Keith Worthington wrote: Hi All, I

Re: [SQL] getting back autonumber just inserted

2005-02-03 Thread Sean Davis
On Feb 3, 2005, at 5:16 PM, lorid wrote: I could have sworn I kept a copy of prior emails that discussed how to get back a value that was just inserted into a autonumber (or in postgresql case a sequence number) See here: http://www.postgresql.org/docs/8.0/interactive/functions- sequence.html

Re: [PERFORM] [SQL] OFFSET impact on Performance???

2005-02-01 Thread Sean Davis
On Jan 26, 2005, at 5:36 AM, Leeuw van der, Tim wrote: Hi, What you could do is create a table containing all the fields from your SELECT, plus a per-session unique ID. Then you can store the query results in there, and use SELECT with OFFSET / LIMIT on that table. The WHERE clause for this temp

Re: [SQL] What's the equivalent in PL/pgSQL

2005-01-27 Thread Sean Davis
res more around that statement. I'm not sure what you mean. Which statement? -Original Message----- From: Sean Davis [mailto:[EMAIL PROTECTED] Sent: Donnerstag, 27. Jänner 2005 14:57 To: KÖPFERL Robert Cc: pgsql-sql@postgresql.org Subject: Re: [SQL] What's the equivalent in PL/pgSQ

Re: [SQL] URL activation through trigger

2005-01-27 Thread Sean Davis
Sandeep, Using pl/perl at least, you could probably do this. My guess is that pl/python (and perhaps pl/R) would offer similar functionality. At least for pl/perl, I think you would need to use the untrusted version and use a module like LWP. I haven't tried this, but I think it should be po

Re: [SQL] What's the equivalent in PL/pgSQL

2005-01-27 Thread Sean Davis
See this section of the manual: http://www.postgresql.org/docs/8.0/interactive/plpgsql-control- structures.html In particular, look at 35.7.1.2 and 35.7.4. I think you need to loop through the results of the query in order to return them. If you just want to return the result set as a whole

Re: [SQL] Constraint on 2 column possible?

2005-01-27 Thread Sean Davis
On Jan 27, 2005, at 6:44 AM, Andrei Bintintan wrote: Hi,   I have a table: CREATE TABLE werke1( id SERIAL, id_hr int4 NOT NULL, id_wk int4 NOT NULL );   CREATE TABLE contact( id SERIAL, type varchar(20), ); It looks like you want a two-column primary key for table contact and then you can refere