Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Date range grouping
I like this one. My true problem is one of date ranges and not specific
dates so I don;lt think a can apply it in this case. However, I WILL
remember it for future reference .
Thanks.
--
Alan D. Mills
Grinberg L. wrote in message <6vsg4g$kpo_at_grant.grant.UUCP>...
>
>
>Try to combine DECODE and SIGN. For example, next statement selects
>one record four sums.
>
>
>SELECT
> sum(decode(sign(trunc(mydate)-trunc(sysdate)), - 1, MyVal,0)) last_sum,
> sum(decode(sign(trunc(mydate)-trunc(sysdate)), 0, MyVal,0)) today_sum,
> sum(decode(sign(trunc(mydate)-trunc(sysdate+1)), 0,MyVal,0))
tomorrow_sum,
> sum(decode(sign(trunc(mydate)-trunc(sysdate+1)), 1,MyVal,0))
>after_tom_sum,
>FROM MyTable;
>
>
>
Received on Mon Oct 12 1998 - 07:21:03 CDT