Re: Please Help with this query!!!!
Date: Thu, 22 Apr 1999 11:33:28 +0200
Message-ID: <7fmqda$bjd$1_at_jaydee.iway.fr>
PGunda <pgunda_at_aol.com> a écrit dans le message :
19990421194858.10002.00000152_at_ng113.aol.com...
> I have a record like this
> Emp_id Week_end_date Monday Tuesday wednesday thurday Friday
> 111 25-apr-99 8 8
8
>
>
> The fields Monday, Tuesday etc holds no_of_hours worked
>
> This one record from the table, in a view I have to show like this
>
> Emp_id Date Hours
> 111 19-apr-99 8
> 111 20-apr-99 0
> 111 21-apr-99 8
> 111 22-apr-99 8
> 111 23-apr-99 0
>
> Is it possible to get it through a sql.
>
> Oracle experts please respond
>
> Thanks in advance
> GR
>
Try :
select emp_id, next_day(week_end_date,1)-7,nvl(monday,0) from My_Table
where emp_id=111
UNION
select emp_id, next_day(week_end_date,2)-7,nvl(tuesday,0) from My_Table
where emp_id=111
UNION
select emp_id, next_day(week_end_date,3)-7,nvl(wednesday,0) from My_Table
where emp_id=111
UNION
select emp_id, next_day(week_end_date,4)-7,nvl(thurday,0) from My_Table
where emp_id=111
UNION
select emp_id, next_day(week_end_date,5)-7,nvl(friday,0) from My_Table
where emp_id=111
/
But it's not optimized because you search 5 times the same records. Received on Thu Apr 22 1999 - 11:33:28 CEST
