Added code to make to fetch column name dynamically for selecting previous maximum value.