Drop a perpendicular to the plane of the ring. Call it P' The distance then is a right triangle that has one side constant, P-P'. Your dq element distances from P can then be determined by the distance expression of the elements of the ring in the x-y plane to P' and the other leg P-P'.
Drop a perpendicular from p to the axis of the coil. Let PP' = x be the the perpendicular. Let O be the center of the coil and R be the radius of the coil. Electric field due to the coil having charge Q is given by
E = kQ*OP'/(R^2 + OP'^2)^3/2
The potential gradient along P'P is given by deltaV = E.dx = E*dx*cos(theta) = -E*dx*x/OP' .Substitute the value of E. Find the integration from x = 0 to x = x.