SYSDATE - What is wrong with this query?
713780Jul 30 2009 — edited Oct 25 2009It works fine in SQL Navigator and I get the counts I'm expecting but when running in Apex I get an error of "ORA-01843: not a valid month". The intent is to run the report for open dates or allow the user to enter start and end date to run the report. Help please.
select ENGINEER "ENGINEER", sum(kount) "Executed Count", count(Kount) "Test Days", trunc(sum(kount)/count(kount),2) "Average"
from (
select to_char(DATE_EXECUTED,'MM/DD/YYYY') exe_date, count(TEST_RECORD_ID) kount, ENGINEER, st.pass
from MX_TEST_RECORD tr, mx_suite st
where tr.suite_id = st.objectid
and productid = '32406.42282.10951.8016'
and status in ('Fail', 'Pass')
and pass like nvl(:P_PASS, '%')
group by to_char(DATE_EXECUTED,'MM/DD/YYYY'), ENGINEER, st.pass
)
where to_date(exe_date, 'MM/DD/YYYY')
between to_date(nvl(:P_START_DATE,'01/01/2000'), 'MM/DD/YYYY')
and to_date(nvl(:P_END_DATE, SYSDATE), 'MM/DD/YYYY')
group by engineer