Made chart SQL compatible between MySQL & Oracle