sql - MS Access Combine tables with like fields -
i want combined result of costs , payments sorted date. query i'm trying:
select clientid, thedate, payment, cost ( select paymentdate thedate, amount payment, clientid payment union select bookeddate thedate, cost, clientid [all bookings query] ) order thedate desc;
it works... however, box pops me enter value "payment" (like field doesn't exist). if leave blank , hit ok, result set "payment" column totally blank, , "cost" column containing amounts both tables. field names i'm using 100% correct.
i think problem union trying squash both tables result 3 columns, , trying select 4. i've never done query quite before don't know how around that.
what want payments , costs in separate columns. wrong query?
you need have 4 columns in each of sub-queries, putting 0 cost column payments , 0 payments column bookings.
select clientid, thedate, payment, cost ( select paymentdate thedate, amount payment, 0 cost, clientid payment union select bookeddate thedate, 0 payment, cost, clientid [all bookings query] ) order thedate desc;
Comments
Post a Comment