Group SQL results by identical trace