Subject | Re: [firebird-support] SQL Help |
---|---|
Author | Dimitry Sibiryakov |
Post date | 2004-04-13T12:07:58Z |
On 13 Apr 2004 at 9:07, Burak ≥ZLER wrote:
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.
>the problem is when a document inserts to this table.[skip]
>must provide this.
>SUM(VALUE) 'B' = SUM(VALUE) 'A'
>I want to write an sql than returns me the document type,ID,SID fieldsSomething like this:
>distinctly that where this equality crashes?
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.