×
The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.
delete from File
where doc_nr || batch_nr in
(select doc_nr || batch_nr from File
group by doc_nr, batch_nr
having sum(amount)=0 )
Regards,
Guy
Tomasz Skorża
<t.skorza@xxxxxxxxxx To: <midrange-l@xxxxxxxxxxxx>
l> cc:
Sent by: Subject: SQL - delete with ... select by two fields?
midrange-l-bounces@m
idrange.com
11/14/2007 12:00 PM
Please respond to
Midrange Systems
Technical Discussion
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
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
http://archive.midrange.com/midrange-l.
As an Amazon Associate we earn from qualifying purchases.