i have 3 tables installation,offices,branches.
installation - id | date | status | reference_by offices - installation id | branch id branches - branch id | branch name
i want display table showing
branch name| successful installation(i.e status=installed)
where branch name column shows list of branches , successful installation shows corresponding bracnches installation count..
try query:
select b.branchname, count(i.status) 'successful installation' branches b inner join offices o on b.branchid = o.branchid inner join installation on o.installationid = i.id i.status = 'installed' --(use clause particular condition on status) group b.brid, b.branchname
probably idea read on sql joins , grouping(http://www.w3schools.com/sql/sql_join.asp) if plan on continuing development in sql.