'How to purge old records from a table automatically using shell script

I have a main table which is having sub partition month wise based on date condition.I have a request for purging out the old records from this main table keeping only the last 24 months of records along with max value and default sub partition. How to write a shell script with a SQL query for this ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source