Re: [SQL] proposal for a CookBook in postgresql.org

2009-05-18 Thread Alvaro Herrera
Pavel Stehule escribió: > 2009/5/18 Alvaro Herrera : > > Pavel Stehule escribió: > > > >> others tricks http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks > > > > There's a lot of good stuff in there ... would you care about > > copying/moving it to wiki.postgresql.org/wiki/Snippets ? > > This

Re: [SQL] proposal for a CookBook in postgresql.org

2009-05-18 Thread Pavel Stehule
2009/5/18 Alvaro Herrera : > Pavel Stehule escribió: > >> others tricks http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks > > There's a lot of good stuff in there ... would you care about > copying/moving it to wiki.postgresql.org/wiki/Snippets ? > This contents is free - and if you would do

Re: [SQL] proposal for a CookBook in postgresql.org

2009-05-18 Thread Alvaro Herrera
Pavel Stehule escribió: > others tricks http://www.postgres.cz/index.php/PostgreSQL_SQL_Tricks There's a lot of good stuff in there ... would you care about copying/moving it to wiki.postgresql.org/wiki/Snippets ? -- Alvaro Herrerahttp://www.CommandPrompt.com/ Po

Re: [SQL] Extrapolating performance expectation

2009-05-18 Thread Rob Sargent
On Mon, May 18, 2009 at 6:47 AM, Kenneth Marshall wrote: > On Sun, May 17, 2009 at 10:04:46PM -0600, Rob Sargent wrote: > > Can one extrapolate future performance expectations for ever-growing > tables > > from a given (non-trivial) data set, and if so with what curve? > Corollary: > > what woul

Re: [SQL] Extract week from date

2009-05-18 Thread Dani Castaños
Dow!!! You’re ok! I forgot the aggregator funciont SUM! Thanks! De: Filip Rembiałkowski [mailto:plk.zu...@gmail.com] Enviado el: lunes, 18 de mayo de 2009 16:54 Para: Dani Castaños CC: pgsql-sql@postgresql.org Asunto: [?? Probable Spam] Re: [SQL] Extract week from date 2009/5/18 Dan

Re: [SQL] Extract week from date

2009-05-18 Thread Filip Rembiałkowski
2009/5/18 Dani Castaños > Hi again, > > I need to extract date grouped by week from an statistics table. > > I was trying something like this: > > SELECT total_duration, EXTRACT( week from date statistics_date ) > FROM statistics_daily > GROUP BY EXTRACT( week from date statistics_date ), total_d

[SQL] Extract week from date

2009-05-18 Thread Dani Castaños
Hi again, I need to extract date grouped by week from an statistics table. I was trying something like this: SELECT total_duration, EXTRACT( week from date statistics_date ) FROM statistics_daily GROUP BY EXTRACT( week from date statistics_date ), total_duration; But it doesn't works... Neither

Re: [SQL] SUM Array values query

2009-05-18 Thread Pawel Socha
2009/5/18 Dani Castaños : > Hi all, > > I've this query including arrays: > > SELECT hour[1:5], statistics_date >  FROM statistics_daily >  WHERE statistics_date = to_date( '03/01/2008', 'DD/MM/' ) > > Result: > >            hour            | statistics_date > +-

Re: [SQL] Extracting data from arrays

2009-05-18 Thread Dani Castaños
Thank you very much! -Mensaje original- De: Pavel Stehule [mailto:pavel.steh...@gmail.com] postgres=# create or replace function sum_items(bigint[]) returns bigint as $$ select sum($1[i])::bigint from generate_series(array_lower($1,1), array_upper($1,1)) g(i)$$ language sql immutable; CR

Re: [SQL] proposal for a CookBook in postgresql.org

2009-05-18 Thread Pavel Stehule
2009/5/18 Gerardo Herzig : > Dave Page wrote: >> On Mon, May 18, 2009 at 1:29 PM, Gerardo Herzig wrote: >> >>> I think this is a good time to propose some kind of CookBook, to >>> preserve this kind of answers. >> >> What, like this one? >> >> http://wiki.postgresql.org/wiki/Snippets >> >> :-) >>

Re: [SQL] proposal for a CookBook in postgresql.org

2009-05-18 Thread Gerardo Herzig
Dave Page wrote: > On Mon, May 18, 2009 at 1:29 PM, Gerardo Herzig wrote: > >> I think this is a good time to propose some kind of CookBook, to >> preserve this kind of answers. > > What, like this one? > > http://wiki.postgresql.org/wiki/Snippets > > :-) > Oops. Yeah, kind of :) Did not see

Re: [SQL] Extracting data from arrays

2009-05-18 Thread Harald Fuchs
In article <162867790905180410n670062b0ud2d7fdd0e652...@mail.gmail.com>, Pavel Stehule writes: > Hello > postgres=# create or replace function sum_items(bigint[]) returns > bigint as $$ select sum($1[i])::bigint from > generate_series(array_lower($1,1), array_upper($1,1)) g(i)$$ language > sql im

Re: [SQL] proposal for a CookBook in postgresql.org

2009-05-18 Thread Dave Page
On Mon, May 18, 2009 at 1:29 PM, Gerardo Herzig wrote: > I think this is a good time to propose some kind of CookBook, to > preserve this kind of answers. What, like this one? http://wiki.postgresql.org/wiki/Snippets :-) -- Dave Page EnterpriseDB UK: http://www.enterprisedb.com -- Sent v

[SQL] proposal for a CookBook in postgresql.org

2009-05-18 Thread Gerardo Herzig
I just saw a beatifull answer from Pavel, as an answer to this question: """ I'm just wondering if there's some way to retrieve the hour column as the > sum of the array values... Just like this: > >hour| statistics_date > +- > 90

Re: [SQL] Extracting data from arrays

2009-05-18 Thread Pavel Stehule
Hello postgres=# create or replace function sum_items(bigint[]) returns bigint as $$ select sum($1[i])::bigint from generate_series(array_lower($1,1), array_upper($1,1)) g(i)$$ language sql immutable; CREATE FUNCTION Time: 2,510 ms postgres=# select sum_items(array[1,2,3,4]); sum_items ---

[SQL] Extracting data from arrays

2009-05-18 Thread Dani Castaños
Hi all, I've this query including arrays: SELECT hour[1:5], statistics_date FROM statistics_daily WHERE statistics_date = to_date( '03/01/2008', 'DD/MM/' ) Result: hour| statistics_date +- {1800,1800,1800,1800,1800} | 2

[SQL] SUM Array values query

2009-05-18 Thread Dani Castaños
Hi all, I've this query including arrays: SELECT hour[1:5], statistics_date FROM statistics_daily WHERE statistics_date = to_date( '03/01/2008', 'DD/MM/' ) Result: hour| statistics_date +- {1800,1800,1800,1800,1800} | 2