You are here: Re: Subtracting two columns from diff tables « MsSQL Server « IT news, forums, messages
Re: Subtracting two columns from diff tables

Posted by MC on 11/29/05 10:49

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@gmail.com> wrote in message
news:1133252899.750115.34110@o13g2000cwo.googlegroups.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
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация