Subject Re: [firebird-support] SQL Help
Author Dimitry Sibiryakov
On 13 Apr 2004 at 9:07, Burak ≥ZLER wrote:

>the problem is when a document inserts to this table.
>must provide this.
>SUM(VALUE) 'B' = SUM(VALUE) 'A'
[skip]
>I want to write an sql than returns me the document type,ID,SID fields
>distinctly that where this equality crashes?

Something like this:

SELECT DISTINCT DOCUMENT_TYPE, DOCUMENT_ID, DOCUMENT_SID FROM DOCUMENTS D
WHERE
(SELECT SUM(VALUE) FROM COMMON_TABLE CA
WHERE CA.DOCUMENT_TYPE = D.DOCUMENT_TYPE AND
CA.DOCUMENT_ID = D.DOCUMENT_ID AND
CA.DOCUMENT_SID = D.DOCUMENT_SID AND
CA.BA = 'A')
=
(SELECT SUM(VALUE) FROM COMMON_TABLE CB
WHERE CB.DOCUMENT_TYPE = D.DOCUMENT_TYPE AND
CB.DOCUMENT_ID = D.DOCUMENT_ID AND
CB.DOCUMENT_SID = D.DOCUMENT_SID AND
CB.BA = 'B')

SY, Dimitry Sibiryakov.