X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (wm.hub.org [200.46.204.128]) by postgresql.org (Postfix) with ESMTP id F1A7A9F9FE1 for ; Sun, 17 Sep 2006 13:16:09 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.128]) (amavisd-new, port 10024) with ESMTP id 05812-07 for ; Sun, 17 Sep 2006 16:16:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from py-out-1112.google.com (py-out-1112.google.com [64.233.166.178]) by postgresql.org (Postfix) with ESMTP id 1A8319F9F7B for ; Sun, 17 Sep 2006 13:16:04 -0300 (ADT) Received: by py-out-1112.google.com with SMTP id d80so4914747pyd for ; Sun, 17 Sep 2006 09:16:03 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:references:x-google-sender-auth; b=tuPQ2CTS4xsO8v8hqcaBLjAsdXyHhtdo2Lpc+6CL05oT/g5YFJ8sK6JJyu8eoSyumPyL0wOStcgz8FAwj4ZhjYfGH/zviqo0pH3gNjjlSTYYVdASaiZxxnD3MVO4NqKvtZWUQaQZYGOX+eTZC+7GWxDcLlOYAqELfXElYSzVG1E= Received: by 10.35.126.7 with SMTP id d7mr21777346pyn; Sun, 17 Sep 2006 09:16:03 -0700 (PDT) Received: by 10.35.80.9 with HTTP; Sun, 17 Sep 2006 09:16:03 -0700 (PDT) Message-ID: Date: Sun, 17 Sep 2006 11:16:03 -0500 From: "Aaron Bono" To: "Becky Hoff" Subject: Re: Dividing results from two tables with different time frames Cc: pgsql-sql@postgresql.org In-Reply-To: <4B2BD8A084A0B442ABF42645DB572A5F28DD4D@fr-fs1.StandonInc.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_47573_23812738.1158509763366" References: <4B2BD8A084A0B442ABF42645DB572A5F28DD4D@fr-fs1.StandonInc.com> X-Google-Sender-Auth: c9315c0fee3dc27a X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.134 tagged_above=0 required=5 tests=HTML_50_60, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200609/119 X-Sequence-Number: 26330 ------=_Part_47573_23812738.1158509763366 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/15/06, Becky Hoff wrote: > > What I'm trying to accomplish is to get two percentages. Both have one > element from one table divided by an element in the other table. > > sum(ds.pulled_loan_total)/sum(dr.loan_starting_balance + > dr.loan_net_change)*100 as pulls_percent, > > and > > (sum(ds.renew_loan_amount)/sum(dr.loan_starting_balance + > dr.loan_net_change))*100 as renew_percent, > > No matter which query I place them in it gives me the wrong data because > of the time frames. How can I get the correct data? > What time frames do you want? Are you looking for daily, monthly or something else? ================================================================== Aaron Bono Aranya Software Technologies, Inc. http://www.aranya.com http://codeelixir.com ================================================================== ------=_Part_47573_23812738.1158509763366 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On 9/15/06, Becky Hoff <bhoff@standoninc.com> wrote:

What I'm trying to accomplish is to get two percentages.  Both have one element from one table divided by an element in the other table.

sum(ds.pulled_loan_total)/sum(dr.loan_starting_balance + dr.loan_net_change)*100 as pulls_percent,

and

(sum(ds.renew_loan_amount)/sum(dr.loan_starting_balance + dr.loan_net_change))*100 as renew_percent,

No matter which query I place them in it gives me the wrong data because of the time frames.  How can I get the correct data?   


What time frames do you want?  Are you looking for daily, monthly or something else?


==================================================================
   Aaron Bono
   Aranya Software Technologies, Inc.
   http://www.aranya.com
   http://codeelixir.com
================================================================== ------=_Part_47573_23812738.1158509763366--