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

Home -> Community -> Usenet -> c.d.o.tools -> Re: How to count working days?

Re: How to count working days?

From: Grzesiek <grzesiek_at_altavista.net>
Date: Wed, 8 Aug 2001 10:29:07 +0200
Message-ID: <9kqt4d$s03$1@news.tpi.pl>

U¿ytkownik "Michel Cadot" <micadot_at_netcourrier.com> napisa³ w wiadomo¶ci news:9kqlrh$q1$1_at_s1.read.news.oleane.net...
>
> "Grzesiek" <grzesiek_at_altavista.net> a écrit dans le message news:
 9kp23c$sog$1_at_news.tpi.pl...
> > Hi!
> > Sorry for such easy question but I've spent preety much time on that
 before
> > asking for help .
> >
> > I've got DATE_1 in TABLE_1 and DATE_2 in TABLE_2.
> > I've got table CALENDAR with 2 columns: DATE, WORKING_DAY [Y/N]
> > All I need is a sql report with
> > DATE_1, DATE_2 and WORKING_DAYS between these two dates.
> >
> > Thanks in advance,
> > Grzesiek
> >
>
> You can do something like:
>
> select a.date_1, b.date_2, sum(decode(c.working_day,'Y',1,0))
> from calendar c,
> (select date_2 from table_2) b,
> (select date_1 from table_1) a
> where c.date between a.date_1 and b.date_2
> group by a.date_1, b.date_2
> /
>
> --
> Have a nice day
> Michel
>
>
>

And now it works! Thank you!
I had report with about 15 columns from 4 tables - and needed extra column counting
those working days and report condition that there are more than 6 working days between
two operation dates.
I checked it out and found that sum(decode(c.working_day,'Y',1,0)) returns one more day than expected so I had to minus one.

Grzesiek Received on Wed Aug 08 2001 - 03:29:07 CDT

Original text of this message

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