Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 63357632726 for ; Wed, 2 Jun 2010 16:44:41 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 79141-04 for ; Wed, 2 Jun 2010 19:44:33 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.magwerks.com (mail.magwerks.com [209.248.233.131]) by mail.postgresql.org (Postfix) with ESMTP id EA98A6321B1 for ; Wed, 2 Jun 2010 16:44:33 -0300 (ADT) Received: from [192.168.1.35] by mail.magwerks.com (GMS 15.01.3664/RS2750.00.1b502c7c) with ESMTP id kboseaaa for pgsql-sql@postgresql.org; Wed, 2 Jun 2010 15:44:35 -0400 Message-ID: <4C06C2A6.8080503@magwerks.com> Date: Wed, 02 Jun 2010 15:44:22 -0500 From: Justin Graf User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.9) Gecko/20100317 Thunderbird/3.0.4 MIME-Version: 1.0 To: Wes James CC: pgsql-sql@postgresql.org Subject: Re: how to construct sql References: =?utf-8?Q?__<597755AB8EE8458F92F4B7C6588E5C03@marktestcr.marktest.pt?= =?utf-8?Q?>_?= In-Reply-To: Content-Type: multipart/mixed; boundary="------------000600040005090200080004" X-AntiSpam: Checked for restricted content by Gordano's AntiSpam Software X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.79 tagged_above=-5 required=5 tests=BAYES_50=0.8, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201006/5 X-Sequence-Number: 34196 This is a multi-part message in MIME format. --------------000600040005090200080004 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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, > > Thx that mostly works. I just tried it and on the days there is only > 1 entry it is 0 since max is the same as min so max - min is 0. Is > there a way to take in to account the 1 entry days? > > Again thx - I appreciate your help :) > > -wes > > Put in a 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) from page_count group by page_count_pdate. All legitimate Magwerks Corporation quotations are sent in a .PDF file attachment with a unique ID number generated by our proprietary quotation system. Quotations received via any other form of communication will not be honored. CONFIDENTIALITY NOTICE: This e-mail, including attachments, may contain legally privileged, confidential or other information proprietary to Magwerks Corporation and is intended solely for the use of the individual to whom it addresses. If the reader of this e-mail is not the intended recipient or authorized agent, the reader is hereby notified that any unauthorized viewing, dissemination, distribution or copying of this e-mail is strictly prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and destroy all occurrences of this e-mail immediately. Thank you. --------------000600040005090200080004 Content-Type: text/x-vcard; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="justin.vcf" begin:vcard fn:Justin Graf n:Graf;Justin org:Magwerks Corp adr:;;501 Commerce Drive;Danville ;IN;46122;USA email;internet:justin@magwerks.com tel;work:317-241-8011 ext 703 tel;fax:317-241-8015 x-mozilla-html:FALSE url:www.magwerks.com version:2.1 end:vcard --------------000600040005090200080004--