Please start any new threads on our new
site at http://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.

Our new SQL Server Forums are live!
Come on over! We've restricted the ability to create new threads on these forums.

quote: (... but I am interested in seeing what the winning solution is)

Chadmat,Fribble, whoever . . . I'll show you mine if you show me yours. (Or if you don't have one, in the case of Chad, I can show you mine and you can just look at it.)

CREATE TABLE #n (n int PRIMARY KEY) INSERT #n SELECT 1 UNION SELECT 2 UNION SELECT 3 UNION SELECT 4 UNION SELECT 5 SELECT CASE WHEN o=a THEN 'DK' WHEN o=b THEN 'EN' WHEN o =c THEN 'DE' WHEN o=d THEN 'NO'ELSE'SE' END yak FROM (SELECT a.n a ,b.n b,c.n c,d.n d,15 -a.n-b.n -c.n-d. n e,e.n f,f. n g,g.n h, h.n i,15 -e.n-f.n-g.n-h.n j,i .n k,j.n l ,k.n m,l.n n,15-i. n-j.n-k.n-l.n o,m.n p,n.n q,o.n r, p.n s,15 -m.n-n.n -o.n-p.n t,q.n u, r.n v,s. n w,t. n x,15 -q.n-r.n -s.n-t.n y FROM #n a,#n b,#n c, #n d,#n e,#n f, #n g,#n h, #n i,#n j,#n k, #n l,#n m,#n n, #n o,#n p,#n q, #n r,#n s,#n t) z WHERE NOT(b=a OR c IN (a,b)OR d IN(a, b,c))AND NOT(g=

f OR h IN(f,g)OR i IN(f,g,h))AND NOT(l=k OR m IN(k,l)OR n IN(k,l,m))AND NOT(q =p OR r IN(q,p)OR s IN(q,p,r))AND NOT(v=u OR w IN(u,v)OR x IN(u,v,w))AND q=g AND x=k AND j=w AND r=3 AND d=1 AND v=p AND 1=ABS(u-l)AND g=i-1 AND 1=ABS(n-w) AND c=y AND 1=ABS(d-f)AND e=m AND 1=ABS(t-u)AND a=s AND b=h DROP TABLE #n

Wow AF! You are the Man. I can't make any sense out of it (My eyes glaze over somwhere in the middle of that sub-query), but it gives the correct answer!

Maybe that is why I gave up after about 10 minutes?