reviewed and fixed the hive sql