SQL Query …… | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

SQL Query ……

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
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;
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??
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