title: how to create procedure/ function in plsql in replacement of static query
body: <p>I wrote following  static query </p>
  
  <pre><code>SELECT (
          SUM(CASE 
                  WHEN DATE BETWEEN add_months('22-MAR-17', 0) - 13
                          AND add_months('22-MAR-17', 0) - 7 THEN VOLUME ELSE 0 END ) ) LAST_WEEK_Volume
                      ,(
                          SUM(CASE 
                                  WHEN DATE BETWEEN add_months('22-MAR-17', 0) - 6
                                          AND add_months('22-MAR-17', 0)
                                      THEN VOLUME
                                  ELSE 0
                                  END)
                          ) THIS_WEEK_Volume FROM abc
          )
          )
  </code></pre>
  
  <p><strong>Problem statemet</strong>- i want to create function for last_Week_volume and this_week_volume and pass it column. can u sugest dynamic query.??
  so that through it will be possible to me calculate day wise last week volume and this week volume  for old two year data </p>