database - SQL Subtract Values From Table 1 When The Row Exists In Table 2 -


i have 2 tables, tbltasks , tbloffsets. tbltasks has of these tasks being funded , tbloffsets has references lines in tbltasks being funded outside money.

both have same columns except tbloffsets has column called "source" keep track of money coming form.

columns

appropriation, performergroup, performer, contract, id, idext, labor, material, travel, fiscalyear


the primary key collection of columns table: appropriation, performergroup, performer, contract, fiscalyear, id, , idext. each row has unique combination of these columns.

now want subquery (or maybe need make new table?) takes tbltasks , subtracts values tbloffsets lines exist in tbloffsets.

i've tried write code doesn't work should give idea of i'm talking about:

select  tb.appropriation, tb.performergroupid, tb.performerid, tb.contract, tb.id, tb.idext, (tb.labor - o.labor) labor, (tb.material - o.material) material, (tb.travel - o.travel) travel  tbltaskbooks tb, tbloffsets o  tbltaskbooks.appropriation = tbloffsets.appropriation ,   tbltaskbooks.performergroupid=  tbloffsets.performergroupid  ,   tbltaskbooks.performerid = tbloffsets.performerid  ,   tbltaskbooks.contract = tbloffsets.contract ,   tbltaskbooks.id = tbloffsets.id ,   tbltaskbooks.idext = tbloffsets.idext ,   tbltaskbooks.fiscalyear = tbloffsets.fiscalyear 

when however, access keeps asking input appropriation , etc. problem 2 tables have different number of rows?


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -