update SQL to use ACOS