Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to query for total days?

Re: How to query for total days?

From: Kendall Willets <kendall_at_willets.org>
Date: Wed, 16 Oct 2002 17:48:44 -0700
Message-ID: <pan.2002.10.16.17.48.43.779.3233@willets.org>


In article <Mhjr9.167514$U7.45873199_at_twister.socal.rr.com>, "Richard Kuhler" <noone_at_nowhere.com> wrote:

> member_id number
> insurer_id number
> eff_dt date -- no time component just the day
> term_dt date -- no time
> component just the day
>
> Q. How many days was each member covered for the month of September
> 2002?
>

Offhand I'd say you should create a table of days and count how many of them are between and eff_dt and a term_dt for some row belonging to the member.

create table sept_days( dt date )

...insert 30 rows...

select member_id, count(*)
from the_first_table i, sept_days d
where d.dt between i.eff_dt and i.term_dt group by member_id Received on Wed Oct 16 2002 - 19:48:44 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US