Home Forums Programming General need help with CASE statement and table joins RE: need help with CASE statement and table joins

  • Because you're only using inner joins, just let the sql engine determine at which step in the process it will handle your where clause.

    (It will take indexes and statistics into account for that to determine its sqlplan )

    select distinct

    a.accountno

    , a.parcelno

    , p.privateflag

    , p.name1

    , p.name2

    , a.businessname

    , ad.address1

    , ad.address2

    , ad.city

    , ad.statecode

    , ad.zipcode

    , ad.province

    , ad.country

    , ad.postalcode

    from tbladdress ad

    inner join tblperson p

    on p.personcode = ad.personcode

    inner join tblacctowneraddress o

    on o.addresscode = ad.addresscode

    and o.personcode = p.personcode

    inner join tblacct a

    on a.accountno = o.accountno

    where a.acctstatuscode = 'A'

    and a.accountno not like 'P%'

    and p.privateflag != '1'

    and o.primaryownerflag = '1'

    and a.verend = '99999999999'

    and p.verend = '99999999999'

    and o.verend = '99999999999'

    and ad.verend = '99999999999'

    order by a.accountno ;

    Johan

    Learn to play, play to learn !

    Dont drive faster than your guardian angel can fly ...
    but keeping both feet on the ground wont get you anywhere :w00t:

    - How to post Performance Problems
    - How to post data/code to get the best help[/url]

    - How to prevent a sore throat after hours of presenting ppt

    press F1 for solution, press shift+F1 for urgent solution 😀

    Need a bit of Powershell? How about this

    Who am I ? Sometimes this is me but most of the time this is me