Added a more complex group by + order by combination
adding second retry condition to deadlocked queries