Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 4EE311337B95 for ; Fri, 26 Nov 2010 09:15:23 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 33304-05 for ; Fri, 26 Nov 2010 13:15:16 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from jupiter.marktest.pt (delta.marktest.pt [80.251.174.116]) by mail.postgresql.org (Postfix) with ESMTP id A46EA1337B77 for ; Fri, 26 Nov 2010 09:15:15 -0400 (AST) Received: from Proteu (proteu.marktest.pt [10.61.90.54]) by jupiter.marktest.pt with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id W4GBP9LT; Fri, 26 Nov 2010 13:15:14 -0000 Message-ID: From: "Oliveiros d'Azevedo Cristina" To: "Michele Petrazzo - Unipex" Cc: References: <4CEF9C66.30100@unipex.it> <4CEFAB4F.6000109@unipex.it> Subject: Re: group by hour + distinct Date: Fri, 26 Nov 2010 13:15:14 -0000 MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1"; reply-type=response Content-Transfer-Encoding: 8bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.5512 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.011 tagged_above=-5 required=5 tests=BAYES_40=-0.001, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201011/70 X-Sequence-Number: 34808 > > Ciao > * Olá! >> for each hour it will count the number of distinct user_id's there >> are . If I understood correctly what you need... >> >> Can you please test it and see if it is OK for your needs? With me, >> it worked on the sample data you provided >> > > Yes! Simply perfect! > * Great to hear it worked ! >> > > Thanks, > Michele * Don't mention it ;-) > > P.s. Have you some references about the "subquery" keyword? I found only > the word subquery as "use" (for example: select a from b where id in > (select id from table)), but not as sql command. > > * I don't know subquery as an SQL keyword too. In the query I gave you the "subquery" thing was just an alias. Such kind of things are mandatory. If I try to omit it, I get this error ERROR: subquery in FROM must have an alias HINT: For example, FROM (SELECT ...) [AS] foo. ********** Erro ********** ERROR: subquery in FROM must have an alias Estado de SQL:42601 Sugestão:For example, FROM (SELECT ...) [AS] foo. So, even though the "subquery" alias was not used anywhere else, I believe it had to be there, otherwise the SQL parser would complain Best, Oliver