DBAsupport.com Forums - Powered by vBulletin
Results 1 to 10 of 34

Thread: Need help in tuning the SQL

Threaded View

  1. #2
    Join Date
    Mar 2002
    Posts
    534
    The following statement is wrong because you compare
    strings and not dates:

    (to_char(l.date_added,'DD/MON/YYYY') >= '01/JAN/2002' and
    to_char(l.date_added,'DD/MON/YYYY') <= '31/DEC/2002')

    A string like '01/DEC/2003' will be smaler than '31/JAN/2003', I guess it's not soemthing you realy want.


    Try the follwing statement and check if it's faster

    select count(distinct l.com_id),l.date_added, a.source
    from tabs a,lis l
    where
    l.date_added >= to_date('01/JAN/2002','DD/MON/YYYY') and
    l.date_added <= to_date('31/DEC/2002','DD/MON/YYYY') and
    l.ad_id = a.ad_id
    group by l.date_added,a.source
    Last edited by mike9; 09-15-2003 at 07:56 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width