Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

open sql statement - delete specific records from the database

0 Kudos
704

Hi,

I have a couple of records that look like this:

TYPE and CODE are each two key fields

The Goal:

The ones marked in red are the records that have to be deleted.

How it works: It should delete the data records which already exist of the TYPE at least 4 times. The smallest CODE should always be deleted.

Important: CODE is a char3 field.

Does anyone know how I can do that with open sql in sap?

Thanks!

1 REPLY 1
Read only

VXLozano
Active Contributor
646

Must it be done with a single SQL statement? If it does, is that a test/exam question? What will we get if we pass the exam for you?
If it's not, why do you bother about the way to do it. Just think about an algorithm that does the work and code it. Using sub-selects you should be able to do that, but I really don't like them, so I will not think about it, sorry.

At least not until you'll show you've put some effort while thinking about it.