Fixed SQL query on dashboard

It did not work properly before on Postgres