updated vertica query