Sql Use Variable In Query In Postgresql A Nested