Get all entries from "the whole week" (begin: Monday end: Sunday) from e.g the day sysdate - 222 (today: 20.10.2004) . This means all entries with a date between 08.03.2004 and 14.03.2004 (including the borders !)
create or replace
procedure whole_week (week date) is
total number(6);
day varchar2(20);
begin
total:=0;
select to_char(sysdate,'day') into day from dual;
if day='montag' then
select sum(total) into total from s_ord where
date_ordered between week-1 and week+5;
else if day='dienstag' then
select sum(total) into total from s_ord where
date_ordered between week-2 and week+4;
else if day='mittwoch' then
select sum(total) into total from s_ord where
date_ordered between week-3 and week+3;
else if day='donnerstag' then
select sum(total) into total from s_ord where
date_ordered between week-4 and week+2;
else if day='freitag' then
select sum(total) into total from s_ord where
date_ordered between week-5 and week+1;
else if day='samstag' then
select sum(total) into total from s_ord where
date_ordered between week-6 and week;
else if day='sonntag' then
select sum(total) into total from s_ord where
date_ordered between week and week+6;
else
dbms_output.put_line('kein tag');
end if;
end if;
end if;
end if;
end if;
end if;
end if;
dbms_output.put_line(total);
end;
/
begin
whole_week(sysdate+1);
end;
/
instead of montag you have to write monday and
so on...i've hat a german version so i've got this names for the days.
montag is monday
dienstag is tuesday
mittwoch is wednesday
donnerstag is thursday
freitag is friday
samstag is saturday
sonntag is sunday
Quick Links:
Do you have
an Oracle Question?
Best regards,
Oracle Database, SQL,
Application, Programming Tips
All the site contents are Copyright © www.sap-img.com
and the content authors. All rights reserved.
All product names are trademarks of their respective
companies.
The site www.sap-img.com is not affiliated with or endorsed
by any company listed at this site.
Every effort is made to ensure the content integrity.
Information used on this site is at your own risk.
The content on this site may not be reproduced
or redistributed without the express written permission of
www.sap-img.com or the content authors.