Re: Subtracting two columns from diff tables



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
<alomrani@xxxxxxxxx> wrote in message
news:1133252899.750115.34110@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> 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
>


.



Relevant Pages

  • RE: Printing wide columns
    ... > I have a spreadsheet that I want to print. ... but the second column is very wide. ... > able to print the first column. ... Prev by Date: ...
    (microsoft.public.excel.misc)
  • Re: Total
    ... >From the sample data you have given what result set are you expecting from ... >I was wondering if i have a table and in the first column ... > second column is the names of product... ... Prev by Date: ...
    (microsoft.public.access.queries)
  • Re: Employee number and name
    ... > first column is the ... > emplyee number and the second is the name. ... > 2 stands for the second column of that table. ... Prev by Date: ...
    (microsoft.public.excel.newusers)
  • RE: Sorting?
    ... if the first column is column A and the second column column D ... Column one is not in ascending or descending order and the order ... Prev by Date: ...
    (microsoft.public.excel.misc)
  • Re: Memory Error while constructing Compound Dictionary
    ... > For the purpose of illustration let's suppose that the first column ... suppose the second column contains a ... this is a prelude to complicated meta-hack programming of the type Python ... in which case you either need a larger machine or a database. ...
    (comp.lang.python)