Same when we do using static SQL, we will be embedding the query between
EXEC SQL Select * from Table1 Order by 1,2 END-EXEC
As an example if you see the difference here, in the dynamic SQL, after order by I have kept two variables WS-Sort1 and WS-Sort2, values can be passed to this section ysung MOVE command.
In some case I need to sort the result using 3rd and 4rth column, so I will pass 3 to WS-Sort1 and 4 to WS-Sort2 through COBOL program.In case I want to sort by first and second column, then I MOVE 1 to WS-Sort1 and 2 to WS-Sort2.
But in case of static SQL, I will always be able to order by 1,2.In case we need to change the order, we need to change it in the query.