Hi There,I have been playing around with a specific query that I just cannot get my head around. I have 2 separate queries that work perfectly, but when I need to merge the data together, or join rather, either my code is wrong or I am just not using the correct method.The first query is as follows:declare @one int , @two intSET @one = (Select sum(DocTotal) as AP1 From oinv where (DocDate >= '2010-01-01 00:00:00.000' and DocDate <= '2010-12-31 23:59:59.000' and CardCode = 'c1003')) SET @two = (select sum(DocTotal) as AP2 From orin where (DocDate >= '2010-01-01 00:00:00.000' and DocDate <= '2010-12-31 23:59:59.000' and CardCode = 'c1003')) select @one 'debit', @two 'credit', (@one-@two)/1.1
This essentially gets me the desired result for a mathematical equation. The second query is as follows:select CardCode, CardName, Phone1, Cellular from ocrd where groupcode='102' and SlpCode='66' order by CardName
As mentioned previously, these work when run by themselves. The question I have is how to merge the data together. The columns should be like this:CardCode CardName Phone1 Cellular (@one-@two)/1.1Hopefully this makes sense, if you need any more information please let me know. I'm really hitting a brick wall with this one.Thanks!