adding sql to invert a matrix