fix in CAST in SQL