Sunday, March 11, 2012

Duduce difference

Hi all,
I have a query that adds up two tables as below:
SELECT SUM(RPAAP / 100) AS [Sales Ledger]
FROM F03B11
SELECT SUM(GBAPYC + GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 +
GBAN06 + GBAN07 + GBAN08 + GBAN09 + GBAN10 + GBAN11 + GBAN12)/100
AS GL
FROM F0902
WHERE (GBAID = '00667809') AND (GBFY = 3)
I would like to take this a step further and deduce the difference
between the two. However I?m not sure how this should be done.
Any help would be most welcome.
Sam
?new person on windows 2000?
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!Use sub queries thus:
select [Sales Ledger] - gl as difference
from
(SELECT SUM(RPAAP / 100) AS [Sales Ledger] FROM F03B11) Q1 join
(SELECT SUM(GBAPYC + GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 + GBAN06
+ GBAN07 + GBAN08 + GBAN09 + GBAN10 + GBAN11 + GBAN12)/100
AS GL
FROM F0902
WHERE (GBAID = '00667809') AND (GBFY = 3)) Q2
Assuming Q2 returns just the one row
"Sam G" <moby@.spamhole.com> wrote in message
news:%23aCWsvTnDHA.2628@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> I have a query that adds up two tables as below:
> SELECT SUM(RPAAP / 100) AS [Sales Ledger]
> FROM F03B11
> SELECT SUM(GBAPYC + GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 +
> GBAN06 + GBAN07 + GBAN08 + GBAN09 + GBAN10 + GBAN11 + GBAN12)/100
> AS GL
> FROM F0902
> WHERE (GBAID = '00667809') AND (GBFY = 3)
> I would like to take this a step further and deduce the difference
> between the two. However I'm not sure how this should be done.
> Any help would be most welcome.
> Sam
> "new person on windows 2000"
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.530 / Virus Database: 325 - Release Date: 22/10/2003|||SELECT SUM(RPAAP / 100) AS [Sales Ledger] -
(SELECT SUM(GBAPYC + GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 +
GBAN06 + GBAN07 + GBAN08 + GBAN09 + GBAN10 + GBAN11 + GBAN12)/100
AS GL
FROM F0902
WHERE (GBAID = '00667809') AND (GBFY = 3))
FROM F03B11
Hope this helps
Wayne Snyder, SQL Server MVP
Computer Education Services Corporation (CESC), Charlotte, NC
www.computeredservices.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Sam G" <moby@.spamhole.com> wrote in message
news:%23aCWsvTnDHA.2628@.TK2MSFTNGP10.phx.gbl...
> Hi all,
> I have a query that adds up two tables as below:
> SELECT SUM(RPAAP / 100) AS [Sales Ledger]
> FROM F03B11
> SELECT SUM(GBAPYC + GBAN01 + GBAN02 + GBAN03 + GBAN04 + GBAN05 +
> GBAN06 + GBAN07 + GBAN08 + GBAN09 + GBAN10 + GBAN11 + GBAN12)/100
> AS GL
> FROM F0902
> WHERE (GBAID = '00667809') AND (GBFY = 3)
> I would like to take this a step further and deduce the difference
> between the two. However I'm not sure how this should be done.
> Any help would be most welcome.
> Sam
> "new person on windows 2000"
>
>
> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!

No comments:

Post a Comment