Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Using GREATEST function in sql where clause causing performance issues

939071Apr 20 2014 — edited Apr 23 2014

SELECT ol.header_id,

               ol.line_id line_id

  FROM oe_order_lines_all ol,

       oe_order_headers_all oh

WHERE oh.header_id = ol.header_id

  AND ol.booked_flag = 'Y'

  AND ol.line_id = ol.top_model_line_id

          AND GREATEST (oh.booked_date, ol.creation_Date) BETWEEN TO_DATE (

                                                                      TO_CHAR (

                                                                         :l_date_from,

                                                                         'DD/MM/YYYY HH24:MI:SS'

                                                                      ),

                                                                      'DD/MM/YYYY HH24:MI:SS'

                                                                   )

                                                               AND  TO_DATE (

                                                                       TO_CHAR (

                                                                          :l_date_to,

                                                                          'DD/MM/YYYY HH24:MI:SS'

                                                                       ),

                                                                       'DD/MM/YYYY HH24:MI:SS'

                                                                    )

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 21 2014
Added on Apr 20 2014
13 comments
1,442 views