Spot all (anti)diagonals with duplicated values


Please login or register to vote for this query.

(click on this box to dismiss)

Stack Overflow

Q&A for professional and enthusiast programmers

DECLARE @ table(v int,x int,y int)

INSERT @ values

SELECT sum(iif(y+x=j+i,1,0)+iif(y-x=j-i,1,0))
FROM @,(SELECT x i,y j,max(y)over()m,v w FROM @)d
  (x*y=0or m=y)
  and v=w
  and x<i

Enter Parameters

Switch sites:
loading Hold tight while we fetch your results