|
------------------------------
message: 8
date: Wed, 14 Nov 2007 18:00:40 +0100
from: Tomasz Skor?a <t.skorza@xxxxxxxxxxx>
subject: SQL - delete with ... select by two fields?
Hi guys
I have File with many fields i.e. doc_nr, batch_nr,
amount and other. (pair
doc_nr and batch_nr are unique)
Then I create select statement:
select doc_nr, batch_nr from File
group by doc_nr, batch_nr
having sum(amount)=0
which take all records with sum of amount = 0 for pair:
doc_nr and batch_nr.
But how I should create DELETE statement which do it for
the same
parameters.
example
File
doc_nr batch_nr amount
1 1 100
1 1 -100
1 2 100
1 2 -120
3 4 100
select take records
doc_nr batch_nr amount
1 1 100
1 1 -100
and this records should be deleted so file after delete
should contain only
doc_nr batch_nr amount
1 2 100
1 2 -120
3 4 100
Have you any idea?
Regards
Tomek
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.