Changed vertica query