Query made consistent with Hive query