Forum Stats

  • 3,851,564 Users
  • 2,263,999 Discussions


How to fetch average of quantity column for a group of columns on weekly basis.

Dimpy Member Posts: 136 Red Ribbon
edited Jan 13, 2021 12:29PM in Social Groups

select dmdunit, dmdgroup, loc, avg(qty) from forecast F where f.startdate between next_day(trunc(sysdate),'SUN')-7 

and (next_day(trunc(sysdate),'SUN')-7)+(7*7) --future 8 weeks

group by f.dmdunit,f.dmdgroup,f.loc;

Above is my query and i want to fetch week wise average qty like wk1_qty,wk2_qty ..... instead of avg(qty).

week 1 would be current week and week2 next week like that..

How can i achieve this?

Kindly help.