SQL Server Performance

SQL Query ......

Discussion in 'T-SQL Performance Tuning for Developers' started by ashoka, May 18, 2007.

  1. ashoka New Member

    select tblmcustomerpackagedetail.packagename, count( *) number_of_customers
    from tblmaccount,tblmcustomerpackagedetail,tblmcustomer,tblmcustomerservicerel
    where tblmcustomer.customerid = tblmcustomerpackagedetail.customerid
    or tblmcustomer.customerid = tblmcustomerservicerel.customerid
    and tblmaccount.accountid = tblmcustomer.accountid
    and tblmaccount.accountstatusid = 'ACS01'
    group by tblmcustomerpackagedetail.packagename;




    This is the query ..im not getting y its not working... as "OR" does not work with the sql queries or wat....plz help me
  2. ranjitjain New Member

    Try this

    select tblmcustomerpackagedetail.packagename, count( *) number_of_customers
    from tblmaccount join tblmcustomer
    ON tblmaccount.accountid = tblmcustomer.accountid
    JOIN tblmcustomerpackagedetail ON
    tblmcustomer.customerid = tblmcustomerpackagedetail.customerid
    JOIN tblmcustomerservicerel ON
    tblmcustomer.customerid = tblmcustomerservicerel.customerid
    where tblmaccount.accountstatusid = 'ACS01'
    group by tblmcustomerpackagedetail.packagename;
  3. ashoka New Member

    thankx its working....but can u plz explain me y tht query is not working i mean all the syntax are proper.....thn wats the problem??
  4. ranjitjain New Member

    Hi,
    If you replace or with AND in your statement, then it should work which is the right condition.
    As I have also pointed the same with JOIN syntax.
    Also it is better to make yourself habitual to using JOIN syntax

Share This Page