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 pa

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 1:51 PM, Plugge, Joe R. wrote: > This is discussed in this Wiki: > > > http://wiki.postgresql.org/wiki/Grouping_Sets > This would sum the results and would be incorrect. I also get this error: select sum(page_count_count), page_count_pdate from page_count group by rollup(

Re: [SQL] how to construct sql

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

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; pgsql-sql@postgr

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 subscri

Re: [SQL] return %ROWTYPE from function

2010-06-02 Thread jr
hi Anton, works fine if you write: create or replace function get_rec (in p_id test.id%TYPE) returns test as $$ -- regards, jr. (j...@tailorware.org.uk) -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsq

[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 retv

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 : > Harrie Rodenbach 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 >> result(id int4, ... > > You need t

[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] 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 to

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 > 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,

Re: [SQL] how to construct sql

2010-06-02 Thread Wes James
On Wed, Jun 2, 2010 at 10:55 AM, Oliveiros 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 on the days there is on

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" To: Sent: Wednesday, June 02, 2010 5:48 PM Subject: [SQL] how to construct sql I am gra

[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