Re: Dividing results from two tables with different time frames - Mailing list pgsql-sql

From Aaron Bono
Subject Re: Dividing results from two tables with different time frames
Date
Msg-id bf05e51c0609201024h415efbb5y8c91d665e488a175@mail.gmail.com
Whole thread Raw
In response to Dividing results from two tables with different time frames  ("Becky Hoff" <bhoff@standoninc.com>)
List pgsql-sql
On 9/18/06, Becky Hoff <bhoff@standoninc.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
==================================================================

pgsql-sql by date:

Previous
From: Harald Fuchs
Date:
Subject: Re: Need a SQL to create sets of hobbies
Next
From: CG
Date:
Subject: Re: Nested loops are killing throughput