I'm getting a missing keyword error in Oracle SQL and I'm not sure why. Here's my code. I want to have a column split by different times depending on the variable P1_DATE_CHOOSER. (I'm using Apex App Developer if that helps).
Select START_DATE, Round(Avg(Run_TIME), 3) as "Average_RunTime", Round(Max(Run_TIME), 3) as "Max_RunTime", Round(Median(Run_time), 3) as "Median_RunTime" from (Select job_id, Case P1_DATE_CHOOSER WHEN 'Daily' THEN TRUNC(start_time) as 'START_DATE' WHEN 'Weekly' THEN to_char(start_time, 'WW') as 'START_DATE' WHEN 'Monthly' THEN to_char(start_time, 'MONTH') as 'START_DATE' END, 1440*(END_TIME - START_TIME)) as "RUN_TIME" from NI_INFA_ACTIVITY_LOG_V order by job_id asc, start_time asc) group by START_DATE order by START_DATE
Any help would be appreciated.