[SQL] how to construct sql

2010-06-02 Thread Wes James
I am grabbing a printer total and putting it in a table. The page_count is continuously increasing: page_count_countpage_count_pdate 10 2010-05-10 20 2010-05-10 40 2010-05-11 60

Re: [SQL] how to construct sql

2010-06-02 Thread Oliveiros
Hi, Have you already tried this out? select MAX(page_count_count) - MIN(page_count_count) from page_count group by page_count_pdate. Best, Oliveiros - Original Message - From: Wes James compte...@gmail.com To: pgsql-sql@postgresql.org Sent: Wednesday, June 02, 2010 5:48 PM

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros oliveiros.crist...@marktest.pt wrote: Hi, Have you already tried this out? select MAX(page_count_count) - MIN(page_count_count)  from page_count group by page_count_pdate. Best, Oliveiros Oliveiros, Thx that mostly works. I just tried it and

Re: [SQL] how to construct sql

2010-06-02 Thread Justin Graf
On 6/2/2010 12:31 PM, Wes James wrote: On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros oliveiros.crist...@marktest.pt wrote: Hi, Have you already tried this out? select MAX(page_count_count) - MIN(page_count_count) from page_count group by page_count_pdate. Best, Oliveiros

Re: [SQL] how to construct sql

2010-06-02 Thread Hiltibidal, Rob
db2 has a group by rollup function.. does this exist in postgres? -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Oliveiros Sent: Wednesday, June 02, 2010 11:55 AM To: Wes James; pgsql-sql@postgresql.org Subject: Re: [SQL] how

[SQL] ODBC-link returns zero rows, allthough query should return 3 rows

2010-06-02 Thread Reinier Suurenbroek
Hi, We are trying to make use of module ODBC-link. We follow the instructions as read in README.TXT, including the given examples. Connecting to an external Oracle database and running a query using unixODBC is successful:

Re: [SQL] Do not understand SETOF RECORD - therefore can not use ODBC-link

2010-06-02 Thread Harrie Rodenbach
Hi, 2010/5/27 Tom Lane t...@sss.pgh.pa.us: Harrie Rodenbach marktenveil...@gmail.com writes: =  oratest=# select odbclink.query(1, 'SELECT * FROM mytable') as result(id int4, t text, d decimal); =  ERROR:  syntax error at or near ( =  LINE 1: ...bclink.query(1, 'SELECT * FROM mytable') as

[SQL] return %ROWTYPE from function

2010-06-02 Thread Anton Prokofiev
Hello, All! I've tried to do following: create table test ( id BIGSERIAL NOT NULL, constraint pk_test primary key (id), val BIGINT NOT NULL ); create or replace function get_rec (in p_id test.id%TYPE) returns test %ROWTYPE as $$ declare

Re: [SQL] safely exchanging primary keys?

2010-06-02 Thread jr
hi Louis-David, tmp := nextval('cabin_type_id_cabin_type_seq'); seems to me you're adding a newly created key value (for which there isn't a record yet). -- regards, jr. (j...@tailorware.org.uk) -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your

Re: [SQL] how to construct sql

2010-06-02 Thread Plugge, Joe R.
This is discussed in this Wiki: http://wiki.postgresql.org/wiki/Grouping_Sets -Original Message- From: pgsql-sql-ow...@postgresql.org [mailto:pgsql-sql-ow...@postgresql.org] On Behalf Of Hiltibidal, Rob Sent: Wednesday, June 02, 2010 12:06 PM To: Oliveiros; Wes James;

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 2:44 PM, Justin Graf jus...@magwerks.com wrote: On 6/2/2010 12:31 PM, Wes James wrote: On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros oliveiros.crist...@marktest.pt  wrote: Hi, Have you already tried this out? select MAX(page_count_count) - MIN(page_count_count)  from

Re: [SQL] how to construct sql

2010-06-02 Thread Justin Graf
On 6/2/2010 2:52 PM, Wes James wrote: **snip*** Thx it is closer (with an end in the case): select case when MAX(page_count_count) - MIN(page_count_count) 0 then MAX(page_count_count) - MIN(page_count_count) else MAX(page_count_count) end as day_max from page_count