>> All I hear when you talk anymore is the teacher from Charlie Brown cartoons.<<
Perhaps you want to take the wax out of your ears. You have a chance to get information from and ask questions of someone who wrote the ANSI/ISO standards for the language in which you are working. I still regret not crashing classes by Edgar Dijkstra at the University of Texas when I moved here.
>> Guess what, Joe, COBOL is still alive and well today. Get off your COBOL bashing. <<
I do not bash COBOL; I am well aware, there are several billion lines of it still in use today. In fact, I kid my younger friends (persons under 40) who brag about whatever the new language du jour they are using is actually nothing more than a COBOL front-end to get things on the cell phones, or whatever. Back in my glory days,no it'soh no what's going ondamn I was a FORTRAN programmer, but I used and learned enough COBOL to modify a timekeeping/payroll program used at Georgia Tech. We were using a CDC 6000 machine that converted the COBOL picture specs into the CDC format floating-point, did the math and reconverted it back faster than the IBM hardware could natively.
The reason you think I'm bashing COBOL is that you don't understand what I'm trying to say. If you want to write COBOL, then right COBOL with its grammar conventions and data model. But don't use those conventions and data models for SQL.
It's kind of like trying to speak German using the syntax and grammar rules of Japanese. Neither languages "wrong", but they are so totally different that they have their own domains. The result is not only inefficiency but incoherency.
When I taught college, for a few decades, I could tell the native language of my students by their programming. I actually did an article on it for the Journal of Structured Programming long ago. If you read from right to left, then the column on which your data is sorted tends to be on the right-hand side. My Chinese students tended to put the exceptions into the if clause, and the regular processing and that then clause of a selection construct. Westerners assumed that the if clause would handle the normal operation. Somewhere long ago I made a list of about 20 or 25 examples of code differences caused by the linguistic model of the programmer.
Please post DDL and follow ANSI/ISO standards when asking for help.