title: Is there a function that will take an existing series of values in oracle SQL for Apex and will make a trendline based on those values?
body: <p>I would like to create a trendline based on the values returned from a query. The logic needs to be applicable for other cases of placing a trendlines on series in Oracle PLSQL with Apex. </p>
  
  <p>My series has X values that are dates and Y values that are time values. Here is my query that outputs my dates and Y values:</p>
  
  <pre><code>Select  
                  null link,
                  (START_DATE) label, 
  
                  Round(Avg(Run_TIME),3) "Average Length"
  
  from 
              (Select job_id,
                      (Case :P4_DATE_CHOOSER 
                           WHEN 'Daily' THEN trunc(start_time)
                           WHEN 'Weekly' THEN trunc(start_time, 'WW')
                           WHEN 'Monthly' THEN trunc(start_time, 'MM') 
                      END) "START_DATE",  
                      1440*(END_TIME - START_TIME) "RUN_TIME"
              from apps.NI_INFA_ACTIVITY_LOG_V@util.world
  
              WHERE
  
          (:P4_JOB_SIZE_CHOOSER = 'Tiny' AND (1440*(END_TIME - START_TIME)) &lt;= 1
          OR
  
          :P4_JOB_SIZE_CHOOSER = 'Small' AND (1440*(END_TIME - START_TIME)) &gt; 1 AND 
                          (1440*(END_TIME - START_TIME)) &lt;= 5
          OR
  
          :P4_JOB_SIZE_CHOOSER = 'Medium' AND (1440*(END_TIME - START_TIME)) &gt; 5 AND 
                          (1440*(END_TIME - START_TIME)) &lt;= 20
          OR
          :P4_JOB_SIZE_CHOOSER = 'Large' AND ((1440*(END_TIME - START_TIME)) &gt; 20)
          OR
          :P4_JOB_SIZE_CHOOSER NOT IN('Small','Medium','Large','Tiny') AND (1440*(END_TIME - START_TIME)) &gt; 0)
  
          AND
          (INFA_TYPE_CODE = 'WORKFLOW')
          AND
          OBJECT_NAME = :P4_WORKFLOWNAMES
          AND
          (
          :P4_Data_Volume_Chooser = 'Small' AND SUCCESS_SOURCE_ROWS &lt; 100
          OR
          :P4_Data_Volume_Chooser = 'Medium' AND SUCCESS_SOURCE_ROWS &gt; 99 AND SUCCESS_SOURCE_ROWS &lt; 10000
          OR
          :P4_Data_Volume_Chooser = 'Large' AND SUCCESS_SOURCE_ROWS &gt; 9999
          OR
          :P4_Data_Volume_Chooser NOT IN ('Small','Medium','Large')
          )
            )
  
          WHERE START_DATE BETWEEN  
                      (Case :P4_DATE_CHOOSER 
                           WHEN 'Daily' THEN trunc(to_date(:P4_BEGIN_DATES, 'MM-DD-YY'))
                           WHEN 'Weekly' THEN trunc(to_date(:P4_BEGIN_DATES, 'MM-DD-YY'), 'WW')
                           WHEN 'Monthly' THEN trunc(to_date(:P4_BEGIN_DATES, 'MM-DD-YY'), 'MM') END) 
  
                  AND
                      (Case :P4_DATE_CHOOSER
                           WHEN 'Daily' THEN trunc(to_date(:P4_END_DATE, 'MM-DD-YY'))
                           WHEN 'Weekly' THEN trunc(to_date(:P4_END_DATE, 'MM-DD-YY'), 'WW')
                           WHEN 'Monthly' THEN trunc(to_date(:P4_END_DATE, 'MM-DD-YY'), 'MM') END)
  
   group by START_DATE 
   order by START_DATE
          ;
  </code></pre>
  
  <p>Ideally, I'd be able to use my existing query as the source for a new subquery.</p>