|
declare @t table (p varchar (max ), x int , y int ) insert into @t select 'p11' , 1 , 1 union select 'p12' , 1 , 2 union select 'p13' , 1 , 3 union select 'p14' , 1 , 4 union select 'p21' , 2 , 1 union select 'p22' , 2 , 2 union select 'p23' , 2 , 3 union select 'p24' , 2 , 4 union select 'p31' , 3 , 1 union select 'p32' , 3 , 2 union select 'p33' , 3 , 3 union select 'p34' , 3 , 4 union select 'p42' , 4 , 2 union select 'p43' , 4 , 3 ;with t (pstart , p, c , x , y ) as ( select p, p, 1 , x , y from @t union all select t . pstart , t . p+ '→' + t_next . p, c + 1 , t_next . x , t_next . y from @t t_next , t where ( (abs (t_next . x - t . x )= 1 and abs (t_next . y - t . y )= 2 ) or (abs (t_next . x - t . x )= 2 and abs (t_next . y - t . y )= 1 ) ) and (CHARINDEX (t_next . p, t . p)= 0 or (c = 14 and t_next . p= t . pstart )) ) select p from t where c = 15 /* p43→p31→p23→p11→p32→p13→p21→p42→p34→p22→p14→p33→p12→p24→p43 p43→p31→p12→p33→p14→p22→p34→p13→p21→p42→p23→p11→p32→p24→p43 p43→p31→p12→p24→p32→p11→p23→p42→p34→p13→p21→p33→p14→p22→p43 p43→p24→p32→p11→p23→p42→p21→p13→p34→p22→p14→p33→p12→p31→p43 ...共112行 */
![]() ;with t as (
select 17 as f1 , 26 as f2 , 20 as f3 , 19 as f4 , 31 as f5 , cast ('' as varchar (8000 )) as path union all select f1 + 8 , f2 + 8 , f3 , f4 , f5 , path + '12上→' from t where f1 < 21 and f2 < 21 union all select f1 + 8 , f2 , f3 + 8 , f4 , f5 , path + '13上→' from t where f1 < 21 and f3 < 21 union all select f1 + 8 , f2 , f3 , f4 + 8 , f5 , path + '14上→' from t where f1 < 21 and f4 < 21 union all select f1 + 8 , f2 , f3 , f4 , f5 + 8 , path + '15上→' from t where f1 < 21 and f5 < 21 union all select f1 , f2 + 8 , f3 + 8 , f4 , f5 , path + '23上→' from t where f2 < 21 and f2 < 21 union all select f1 , f2 + 8 , f3 , f4 + 8 , f5 , path + '24上→' from t where f2 < 21 and f4 < 21 union all select f1 , f2 + 8 , f3 , f4 , f5 + 8 , path + '25上→' from t where f2 < 21 and f5 < 21 union all select f1 , f2 , f3 + 8 , f4 + 8 , f5 , path + '34上→' from t where f3 < 21 and f4 < 21 union all select f1 , f2 , f3 + 8 , f4 , f5 + 8 , path + '35上→' from t where f3 < 21 and f5 < 21 union all select f1 , f2 , f3 , f4 + 8 , f5 + 8 , path + '45上→' from t where f4 < 21 and f5 < 21 union all select f1 - 13 , f2 - 13 , f3 , f4 , f5 , path + '12下→' from t where f1 > 25 and f2 > 25 union all select f1 - 13 , f2 , f3 - 13 , f4 , f5 , path + '13下→' from t where f1 > 25 and f3 > 25 union all select f1 - 13 , f2 , f3 , f4 - 13 , f5 , path + '14下→' from t where f1 > 25 and f4 > 25 union all select f1 - 13 , f2 , f3 , f4 , f5 - 13 , path + '15下→' from t where f1 > 25 and f5 > 25 union all select f1 , f2 - 13 , f3 - 13 , f4 , f5 , path + '23下→' from t where f2 > 25 and f2 > 25 union all select f1 , f2 - 13 , f3 , f4 - 13 , f5 , path + '24下→' from t where f2 > 25 and f4 > 25 union all select f1 , f2 - 13 , f3 , f4 , f5 - 13 , path + '25下→' from t where f2 > 25 and f5 > 25 union all select f1 , f2 , f3 - 13 , f4 - 13 , f5 , path + '34下→' from t where f3 > 25 and f4 > 25 union all select f1 , f2 , f3 - 13 , f4 , f5 - 13 , path + '35下→' from t where f3 > 25 and f5 > 25 union all select f1 , f2 , f3 , f4 - 13 , f5 - 13 , path + '45下→' from t where f4 > 25 and f5 > 25 union all select f1 + 8 , f2 + 8 , f3 , f4 , f5 , path + '12上→' from t where f1 < 21 and f2 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 + 8 , f2 , f3 + 8 , f4 , f5 , path + '13上→' from t where f1 < 21 and f3 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 + 8 , f2 , f3 , f4 + 8 , f5 , path + '14上→' from t where f1 < 21 and f4 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 + 8 , f2 , f3 , f4 , f5 + 8 , path + '15上→' from t where f1 < 21 and f5 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 , f2 + 8 , f3 + 8 , f4 , f5 , path + '23上→' from t where f2 < 21 and f2 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 , f2 + 8 , f3 , f4 + 8 , f5 , path + '24上→' from t where f2 < 21 and f4 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 , f2 + 8 , f3 , f4 , f5 + 8 , path + '25上→' from t where f2 < 21 and f5 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 , f2 , f3 + 8 , f4 + 8 , f5 , path + '34上→' from t where f3 < 21 and f4 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 , f2 , f3 + 8 , f4 , f5 + 8 , path + '35上→' from t where f3 < 21 and f5 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 union all select f1 , f2 , f3 , f4 + 8 , f5 + 8 , path + '45上→' from t where f4 < 21 and f5 < 23 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 ) select path from t where f1 between 21 and 25 and f2 between 21 and 25 and f3 between 21 and 25 and f4 between 21 and 25 and f5 between 21 and 25 /* 34上→45下→45上→35下→35上→15上→25下→25上→ 34上→45下→45上→35下→35上→14上→24下→24上→ 34上→35下→35上→45下→45上→15上→25下→25上→ 34上→35下→35上→45下→45上→14上→24下→24上→ */ |






骆驼户外男 真皮磨砂日常休闲鞋 低帮 2011秋冬新款 专柜正品特价