I have a table with multiple transaction types. Currently I'm only pulling the adjustments and payments, but I am needing to match the IDs of the types to their descriptions. For example, my transactions table has paytype_id
and adjustment_id
which range 1-100 for each. I have two other tables dbo.paytype
and dbo.adjustments
that have the distinct paytype_id
and adjustment_id
along with the pay_desc
and adj_desc
fields that describe what kind they are. Issue I'm running into is that any given transaction will only have a paytype_id
or an adjustment_id
but not both. So if I attempt to join one table, then the other I lose the NULL values of the secondary IDs
This query will pull the paytype_id
descriptions but will remove any transactions with adjustment_id
due to the payment_id
being NULL for them.
SELECT
t.tran_num, t.resp_party_id, t.Total,
t.paytype_id, t.adjustment_id, t.clinic,
t.date_entered, p.pay_desc
FROM
adjpay_vw t
CROSS JOIN
paytype p
WHERE
(t.paytype_id = p.paytype_id AND t.clinic = p.clinic)
So I'm wondering how I can pull both the adj_desc
from dbo.adjustments
and the pay_desc
from dbo.paytype