472,986 Members | 2,902 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,986 software developers and data experts.

Subtracting two columns from diff tables

Hi all,

I encountered this small problem

I have two tables A and B with two columns 1 and 2 each, I would like
the first column of each table when match the first in the second table
is to subtract the second column

so the result would look as follows

Column 1 | Columnn 2
where A1=B1 | A2-B2

Now this is no problem so far ..

But if there was no corresponding value in column 1 in either tables ..
i.e. field A1 doesnt exist in Table B column 1, IT SHALL DO A2 - 0; or
0-B2 ..

NOW How can that be achieved ?

Thanks all for your help

Nov 29 '05 #1
3 14670
MC
Does this work for you?

select
isnull(A.A2,0) - isnull(B.B2,0) as Diff
from
tableA A
full outer join tableB B on A.A1 = B.B1
MC
<al******@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hi all,

I encountered this small problem

I have two tables A and B with two columns 1 and 2 each, I would like
the first column of each table when match the first in the second table
is to subtract the second column

so the result would look as follows

Column 1 | Columnn 2
where A1=B1 | A2-B2

Now this is no problem so far ..

But if there was no corresponding value in column 1 in either tables ..
i.e. field A1 doesnt exist in Table B column 1, IT SHALL DO A2 - 0; or
0-B2 ..

NOW How can that be achieved ?

Thanks all for your help

Nov 29 '05 #2
Hi,

Select ISNULL(Table1.col2,0) - ISNULL(Table2.col2,0)
FROm Table1
FULL OUTER JOIN Table2
ON Table1.Col1 = Table2.Col1

HTH, Jens Suessmeyer.

Nov 29 '05 #3
Hi all

thanks alot jens and mc i could easily figure it out.
regards

Nov 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Robert Schoenert | last post by:
I want to be able to subtract two time fields, one starting before midnight and the other past midnight. example: starttime 23:00 and endtime 01:10 The answer is 1:10. How can I do this with...
13
by: scorpion53061 | last post by:
Very urgent and I am very close but need a little help to get me over the edge........ I need to write these columns to a html file with each row containing these columns (seperated by breaks)....
10
by: Brian Henry | last post by:
How would i take two dates startdate and enddate and subtract startdate from enddate to figure the number of days between the two? thanks
9
by: Mike Fellows | last post by:
i have 2 dates one is todays date and the other is a future date i want to take todays date from ther future date and tell me how many days difference this is thanks in advance Mike...
6
by: Igor Shevchenko | last post by:
Hi! Suppose I have "pg_dump -s" of two pg installs, one is "dev", another is "production". Their schemas don't differ too much, and I want to get a "diff -u"-like schema diff so I can quickly...
0
by: mariat101 | last post by:
I am collecting patient information when they do not show for an apt. I've created 4 tables linked by autonum b/c I have 3 of them in a form as subforms b/c they want to be able to see everything on...
5
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can...
1
by: Lennart | last post by:
diff -u /home/system/db2inst1/nya/bin/db2filter.py ./db2filter.py --- /home/system/db2inst1/nya/bin/db2filter.py 2007-01-12 15:23:34.000000000 +0100 +++ ./db2filter.py 2007-04-14...
2
by: parkc | last post by:
I want to return the difference number of records. Here are the queries: --subtracting columns with columns and descriptions (columns - columns and descriptions) --difference of 30 records...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.