Create A SubQuery

S

Sinfash

Hello I don't know how to do it:

I want to make a Subquery that create a field form sum two created fields in
the main query.

This is the main query:
SELECT Movimientos.Cta, Sum(Movimientos.Debe) AS SumOfDebe,
Sum(Movimientos.Haber) AS SumOfHaber, Cuentas.Naturaleza
FROM Cuentas INNER JOIN Movimientos ON Cuentas.Siglas = Movimientos.Cta
GROUP BY Movimientos.Cta, Cuentas.Naturaleza
HAVING (((Cuentas.Naturaleza)="debe"));

Well i want to use SumofDebe and SumOfHaber for create Resta= SumofDebe -
SumOfHaber
When i make it in the main Query ask me for the two fields but i don't want
that the machine askme for the fields becouse this will be created.
 
M

MGFoster

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

SELECT

Movimientos.Cta,
Sum(Movimientos.Debe) AS SumOfDebe,
Sum(Movimientos.Haber) AS SumOfHaber,
Cuentas.Naturaleza,
Sum(Movimientos.Debe) - Sum(Movimientos.Haber) AS Resta

FROM Cuentas INNER JOIN Movimientos ON Cuentas.Siglas =
Movimientos.Cta
WHERE Cuentas.Naturaleza)="debe"
GROUP BY Movimientos.Cta, Cuentas.Naturaleza


MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQC2tbIechKqOuFEgEQKksQCg7m1JmGETFYcxJ35op0F9+8qXp8kAnjsY
meYYzxZbeddxs642NMXc27zw
=ZqVM
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top