From: "Grzesiek" <grzesiek@altavista.net>
Newsgroups: comp.databases.oracle.misc
Subject: Re: How to count working days?
Date: Wed, 8 Aug 2001 10:29:07 +0200
Organization: tp.internet - http://www.tpi.pl
Lines: 50
Message-ID: <9kqt4d$s03$1@news.tpi.pl>
References: <9kp23c$sog$1@news.tpi.pl> <9kqlrh$q1$1@s1.read.news.oleane.net>
Reply-To: "Grzesiek" <grzesiek@altavista.net>
NNTP-Posting-Host: 195.205.152.10
X-Trace: news.tpi.pl 997259213 28675 195.205.152.10 (8 Aug 2001 08:26:53 GMT)
X-Complaints-To: usenet@tpi.pl
NNTP-Posting-Date: 8 Aug 2001 08:26:53 GMT
X-Newsreader:  Microsoft Outlook Express 5.50.4522.1200
X-MSMail-Priority:  Normal
X-Priority:  3
X-MimeOLE:  Produced By Microsoft MimeOLE V5.50.4522.1200



U¿ytkownik "Michel Cadot" <micadot@netcourrier.com> napisa³ w wiadomo¶ci
news:9kqlrh$q1$1@s1.read.news.oleane.net...
>
> "Grzesiek" <grzesiek@altavista.net> a écrit dans le message news:
 9kp23c$sog$1@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




