Hello
I do not know how to combine different SELECT statements into one coherent query. Essentially, I am trying to find active links to entities for a particular file code ‘BROW16’.
These are my statements and the results that they yield separately:
Statement 1:
SELECT DISTINCT R.FileCode FROM ReportAccounts R JOIN RefMaster M ON R.FileCode=M.RefCode WHERE R.AcctHolder='BROW16' AND R.AcctStatus='A' AND M.Status='0'
yields no results
Statement 2:
SELECT DISTINCT O.EntCode FROM Officers O JOIN RefMaster M ON O.EntCode=M.RefCode WHERE O.AddrCode='BROW16' AND O.Status='A' AND M.Status='0'
yields three results:
006850
007193
TESTLL
Statement 3:
SELECT I.RefCode FROM RefMaster I WHERE I.Cl_IntroBy='BROW16' AND I.Status='0'
yields no results
Statement 4:
SELECT CL.EntCode FROM Entity CL WHERE CL.EntClient='BROW16' AND CL.Status IN ('0', '1')
yields one result:
ADTECH
Statement 5:
SELECT CO.EntCode FROM Entity CO WHERE CO.ContactAddrCode='BROW16' AND CO.Status IN ('0', '1')
yields three results:
006850
008034
ADTECH
What I would like to do is be able to combine all 5 statements into one, eliminating any null and duplicated results and, if possible, having them appear in one row separated by a semi-colon ( and a space.
In summary, I need a statement that will, ideally, return:
006850; 007193; TESTLL; ADTECH; 008034
The order of the codes does not matter.
Is this possible and how would I go about it?
Thank you for your assistance.
Taryn