Hi,
try:
select
sum(decode(to_char( CELEBRATE, 'Q'), '1',1,0)) q1,
sum(decode(to_char( CELEBRATE, 'Q'), '2',1,0)) q2,
sum(decode(to_char( CELEBRATE, 'Q'), '3',1,0)) q3,
sum(decode(to_char( CELEBRATE, 'Q'), '4',1,0)) q4,
count(pk_field) total
from
HOLIDAY
lakkundi_at_msn.com schrieb:
>
> A client wants us to list the number of occurrences of holidays
> celebrated by quarter from
>
> the holiday table. (Holiday table eg. below)
>
> HOLIDAY ACTUALDAT CELEBRATE
> ------------------------- --------- ---------
> NEW YEAR DAY 01-JAN-95 01-JAN-95
> MARTIN KING, JR. 15-JAN-95 16-JAN-95
> LINCOLNS BIRTHDAY 12-FEB-95 20-FEB-95
> VALENTINES DAY 14-FEB-95 14-FEB-95
> MEMORIAL DAY 30-MAY-95 29-MAY-95
>
> The output should have column headings that are Q1, Q2, Q3 etc. and look
> like the following:
>
> Title Q1 Q2 Q3 Q4 Total
> Holiday Occurrence 2 5 2 1 10
>
> Any tips greatly appreciated.
>
> I have tried but it does not well:
> sum(decode(to_char(CELEBRATEDDATE, 'Q'),1,NULL)) Q1,
> sum(decode(to_char(CELEBRATEDDATE, 'Q'),2,1,NULL)) Q2
>
> Thanks‰
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
Regards
Matthias Gresz :-)
Matthias.Gresz_at_Privat.Post.DE
Always log on the bright side of life.
http://www.stone-dead.asn.au/movies/life-of-brian/brian-31.htm
Received on Thu Nov 05 1998 - 08:15:02 CST