I have to put together two queries that do not have a common value but both instances must be accounted for on one report
select giftid,giftamount,coreid,address
from gifts
left outer join core
on giftid=coreid
left outer join address
on giftid=addrid
select jobid,coreid,address
from jobs
left outer join core
on jobsid=coreid
left outer join address
on jobs=addrid
essentially a person can give a gift and not be an employee. Transversely a person can be an employee and not have given anything.
I thought about creating two temp tables but is is better to list both queries and do a union statement
Any best practices ideas that also takes into account optimization? The reason is the code must be saved and used in a crystal report for output. Also a person can only have one coreid so I also want to select a distinct coreid
select giftid,giftamount,coreid,address
from gifts
left outer join core
on giftid=coreid
left outer join address
on giftid=addrid
select jobid,coreid,address
from jobs
left outer join core
on jobsid=coreid
left outer join address
on jobs=addrid
essentially a person can give a gift and not be an employee. Transversely a person can be an employee and not have given anything.
I thought about creating two temp tables but is is better to list both queries and do a union statement
Any best practices ideas that also takes into account optimization? The reason is the code must be saved and used in a crystal report for output. Also a person can only have one coreid so I also want to select a distinct coreid