Don't know if I understood your question correctly, but sounds like you're talking about WHERE clause of a SELECT statement. See:
WHERE (Transact-SQL)[
^]
Update based on the comment:
I suggest that you slice this to smaller pieces.
First to get the data from the database, you proper select statement. Based on your description it could be something like:
select *
from company c
branch b
transation t
where b.companyid = c.companyid
and t.branchid = c.branchid
and c.companyid = @companyid
In the previous @companyid is a variable containing proper value.
The next step is the format. If you're required to deliver the results, what's the format to be used? If you're running this query in SSMS by yourself, you can export the data in csv or txt by right clicking on the result grig and selecting Save results. You can also run the results into XML. See:
http://msdn.microsoft.com/en-us/library/ms173812.aspx[
^] so you can create a small stored procedure which would run the query and possibly format the results.
Third question, how the results should be delivered? If via mail, then you can use for example
http://msdn.microsoft.com/en-us/library/ms190307.aspx[
^]