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

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -