fix join statements for ordering, make sure we dont retur early if no where query