First, I see some problems in your query. I would be *VERY* surprised if it executes without error. The main problems I see are in these four "where" clauses that include "to_date":
AND ((cci.SOLVEDDATE >= trunc(to_date('26/06/2009'
and cci.SOLVEDDATE <= to_date('01/07/2009','dd/m
or (cci.CLOSEDDATE >= trunc(to_date('26/06/2009'
and cci.CLOSEDDATE <= to_date('01/07/2009','dd/m
You never need to combine "trunc" plus "to_date" when you supply a literal value like: "26/06/2009" that does *NOT* include a time component! That value is already truncated! Then, your format mask: 'dd/mm/yyyy hh:mi:ss AM' does not match the literal value '26/06/2009'. For that value, you need a shorter format mask of just: 'dd/mm/yyyy'.
Next, I do not like to see the "distinct" keyword in an Oracle query. That can cause lots of overhead to do a sort, if the sort is not needed. And, if you ever include date columns that include a non-midnight time-of-day component, Oracle's interpretation of "distinct" may be different from what most users expect.
Finally, SQL queries by default return fixed-length ASCII values. If you run SQL queries in SQL*Plus or TOAD is it easy to "spool" this output to plain text files that tools like Excel can then open.
Which tool or program do you plan to use to run the SQL statement? Maybe that tool offers the ability to convert the output to Excel format, but SQL by itself does not. Also, SQL does not do e-mail. But whatever tool you plan to use to run the SQL statement may be able to do send an e-mail and include the output as an attached file.
Main Topics
Browse All Topics





by: rolutolaPosted on 2009-07-10 at 06:04:22ID: 24822779
Yes you can mail the output using shell script or using Oracle UTL_SMTP.
Are you running unix/Linux or Windows?
R.