fixing the queries to show the null values at the end