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

[SQL] Extract week from date

2009-05-18 Thread Dani Castaños
works... Neither: SELECT total_duration, statistics_date FROM statistics_daily GROUP BY EXTRACT( day from statistics_date ), total_duration, statistics_date; How can it be done? Note: statistics_date is a DATE data type column. Regards. -- Dani Castaños Sánchez dcasta...@androme.es -- Sent via pgsq

Re: [SQL] Extracting data from arrays

2009-05-18 Thread Dani Castaños
; CREATE FUNCTION Time: 2,510 ms postgres=# select sum_items(array[1,2,3,4]); sum_items --- 10 (1 row) regards Pavel Stehule 2009/5/18 Dani Castaños : > Hi all, > > I've this query including arrays: > > SELECT hour[1:5], statistics_date > FROM st

[SQL] Extracting data from arrays

2009-05-18 Thread Dani Castaños
3 Hour is a bigint[] array column. My version of postreSQL is 8.1.9 Thank you in advanced! -- Dani Castaños Sánchez dcasta...@androme.es -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql

[SQL] SUM Array values query

2009-05-18 Thread Dani Castaños
3 Hour is a bigint[] array column. My version of postreSQL is 8.1.9 Thank you in advanced! P.S.: Sorry if I had send it before, but I think I was not subscribed to the mailist. -- Dani Castaños Sánchez dcasta...@androme.es -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make

[SQL] Different Query plans filtering between dates

2007-12-24 Thread Dani Castaños
Hi all! I'm trying to find out a solution for this. I paste you two queries and their query plans: SELECT se.enduser_id , se.enduser_number , se.points , se.total_messages , sm.message_order , to_char( se.creation_time, 'DD/MM/ HH24:MI:SS' ) as first , MAX( to_char( s.times

[SQL] Get different sums from the same table in one query

2007-10-08 Thread Dani Castaños
Hi all! I want to put this three queries in only one... Take a look that the only thing that changes is the message_type_id. Any suggestions?? SELECT TO_CHAR( statistics_date, 'DD/MM/') AS date_in, sum(total_num_messages) FROM statistics_daily WHERE message_type_i

[SQL] Database creation script

2007-08-22 Thread Dani Castaños
hat do you think about this way of doing? Which is the best option to do it? Thanks in advance! Dani Castaños ---(end of broadcast)--- TIP 4: Have you searched our list archives? http://archives.postgresql.org

Re: [SQL] Foreign Key inter databases

2007-08-03 Thread Dani Castaños
Josh Tolley escribió: On 8/2/07, Dani Castaños <[EMAIL PROTECTED]> wrote: Hi all! Is it possible to have a foreign key where referenced table is in another database? Thank you in advance ---(end of broadcast)--- TIP 1: if posting/r

[SQL] Foreign Key inter databases

2007-08-02 Thread Dani Castaños
Hi all! Is it possible to have a foreign key where referenced table is in another database? Thank you in advance ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail command to [EMA

Re: [SQL] Having the sum of two queries

2007-07-17 Thread Dani Castaños
Thank you all! My problem has been solved in another way... because the inner queries had left outer joins and so on, and I finally have had to do two queries and treat results by PHP. Again... thank you all! ---(end of broadcast)--- TIP 2: Don'

[SQL] Having the sum of two queries

2007-07-16 Thread Dani Castaños
Hi all! I want to do something like this: SELECT status, COUNT( status ) AS total FROM users GROUP BY status UNION SELECT status, COUNT(status) AS total FROM imported_users GROUP BY status And have the result of both added. I've tried something like SELECT tot.status, COUNT(total) FROM( QU

Re: [SQL] Results per letter query

2007-06-21 Thread Dani Castaños
A. Kretschmer escribió: am Thu, dem 21.06.2007, um 12:59:05 +0200 mailte Dani Castaños folgendes: change the generate_series(65,90) to generate_series(32,90) Andreas With only changing 65 to 32: ERROR: invalid regular expression: parentheses () not balanced I think, it

Re: [SQL] Results per letter query

2007-06-21 Thread Dani Castaños
am Thu, dem 21.06.2007, um 12:42:52 +0200 mailte Dani Castaños folgendes: test=*# select chr(x), count(1) from generate_series(65,90) x, w where upper(substring (w.t from 1 for 1)) ~ chr(x) group by 1; chr | count -+--- T | 1 B | 1 F | 2 (3 rows) Andreas

Re: [SQL] Results per letter query

2007-06-21 Thread Dani Castaños
Hi! I'm trying to build a query to get if there is an occurrence for a field for each alphabetical letter. My first thought to know it was to do something like: SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'A%' ) LIMIT 1; SELECT COUNT(field) FROM table WHERE UPPER( field

[SQL] Results per letter query

2007-06-21 Thread Dani Castaños
Hi! I'm trying to build a query to get if there is an occurrence for a field for each alphabetical letter. My first thought to know it was to do something like: SELECT COUNT(field) FROM table WHERE UPPER( field ) LIKE UPPER( 'A%' ) LIMIT 1; SELECT COUNT(field) FROM table WHERE UPPER( field )