Re: Dividing results from two tables with different time frames

From: "Aaron Bono" <postgresql(at)aranya(dot)com>
To: "Becky Hoff" <bhoff(at)standoninc(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Dividing results from two tables with different time frames
Date: 2006-09-20 17:24:09
Message-ID: bf05e51c0609201024h415efbb5y8c91d665e488a175@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 9/18/06, Becky Hoff <bhoff(at)standoninc(dot)com> wrote:
>
> The sum(dr.loan_starting_balance + dr.loan_net_change) part of the
> calculation have a single date, the last day in a date range chosen by the
> user
>
>
>
> Sum(ds.pulled_loan_total) and sum(ds.renew_loan_amount) both have a range
> of dates chosen by the user
>
>
>
> What I need it the result of the second expression divided by the result
> of the first expression.
>

Can you provide some data examples. Show a sample of the data you have to
query, what results you are getting and what results you are really wanting
so we can see where your queries are not giving you what you need.

By your post it sounds like you just need to join your two queries and then
use the formula:
Sum(ds.pulled_loan_total) and sum(ds.renew_loan_amount) / sum(
dr.loan_starting_balance + dr.loan_net_change)

but if it were this simple you probably would have it figured out by now.
Data examples help us help you much better.

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

Browse pgsql-sql by date

  From Date Subject
Next Message CG 2006-09-20 18:10:42 Re: Nested loops are killing throughput
Previous Message Harald Fuchs 2006-09-20 11:33:01 Re: Need a SQL to create sets of hobbies