''''4'''' || (&1 - j) 新值 15: (i - 1) || ''''4'''' || (5 - j) 原值 17: from (select level as i from dual connect by level <= &1) a, 新值 17: from (select level as i from dual connect by level <= 5) a, 原值 18: (select level as j from dual connect by level <= &1) b 新值 18: (select level as j from dual connect by level <= 5) b
STR --------------------------------------------------------------------------------------------
1 16 15 14 13 2 17 24 23 12 3 18 25 22 11 4 19 20 21 10 5 6 7 8 9
SQL>-------------------------------------------------------------------------------- 使用前, 给声明m和n并赋值
代码:-------------------------------------------------------------------------------- var n number; var m number;
exec :n := &n; :m=&m;
with t as ( select :n as n, :m as m from dual ) select replace(max(sys_connect_by_path(rank, '''','''')), '''','''') str from (select i, j, to_char(rank() over(order by tag), ''''999999'''') as rank from (select i, j, -- 顺时针螺旋特征码 clockwise case least(i - 1, m - j, n - i, j - 1) when i - 1 then to_char(i - 1, ''''fm0000'''') || ''''1'''' || to_char(j - 1, ''''fm0000'''') when m - j then to_char(m - j, ''''fm0000'''') || ''''2'''' || to_char(i - 1, ''''fm0000'''') when n - i then to_char(n - i, ''''fm0000'''') || ''''3'''' || to_char(m - j, ''''fm0000'''') when j - 1 then to_char(j - 1, ''''fm0000'''') || ''''4'''' || to_char(n - i, ''''fm0000'''') end as tag from (select n, level as i from t connect by level <= n) a, (select m, level as j from t connect by level <= m) b)) start with j = 1 connect by j - 1 = prior j and i = prior i group by i -----------------------------------------------------------------------------------------------
__________________ 平凡的伟大, 伟大的平凡
msn : jackywood_24@hotmail.com
上一页 [1] [2] [3] [4] [5] [6] |