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: calendar.sql

Re: calendar.sql

From: DA Morgan <damorgan_at_x.washington.edu>
Date: Mon, 22 Nov 2004 19:44:41 -0800
Message-ID: <1101181392.594780@yasure>


Oradba Linux wrote:

> From connor mcdonald's mastering oracle pl/sql , i am not able to understand
> the logic for using the colum p. The query is below.
>
> select
> max(decode(dow,1,d,null)) Sun,
> max(decode(dow,2,d,null)) Mon,
> max(decode(dow,3,d,null)) Tue,
> max(decode(dow,4,d,null)) Wed,
> max(decode(dow,5,d,null)) Thu,
> max(decode(dow,6,d,null)) Fri,
> max(decode(dow,7,d,null)) Sat
> from (
> select rownum d ,
>
> rownum-2+to_number(to_char(trunc(to_date('&CALDATE','DD-MON-YYYY'),'MM'),'D'
> ))p,
> to_char(trunc(to_date('&CALDATE','DD-MON-YYYY'),'MM')-1+rownum,'D')
> dow
> from all_objects
> where rownum <=to_number(to_char(last_day(to_date(sysdate)),'DD'))
> )
> group by trunc(p/7)
> /

'p' isn't a column ... it is an alias juast as is 'dow'.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)
Received on Mon Nov 22 2004 - 21:44:41 CST

Original text of this message

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