Select Query In Postgresql With Where Clause With Inner