12
返回列表 发新帖
楼主: 〇〇

能用SQL根据sgf棋谱输出最终局面

[复制链接]
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
11#
 楼主| 发表于 2016-3-16 10:48 | 只看该作者
思路差不多
with mv as(
select l,substr(s,2,1)e,substr(s,-2,1)x,substr(s,-1)y from(
select level l,regexp_substr(moves,';[WB]\[[a-z]{2}',1,level)s from goes connect by level<=200)),
m as(select mv.*,row_number()over( partition by x,y order by l desc)rn from mv ),
t as(select chr(96+level) l from dual connect by level<=19)
select yl,
case yl when 'a' then listagg(decode(e,'W','○','B','●',decode(xl,'a','┌','s','┐','┬'))) within group(order by xl)
when 's' then listagg(decode(e,'W','○','B','●',decode(xl,'a','└','s','┘','┴'))) within group(order by xl)
else listagg(decode(e,'W','○','B','●',decode(xl,'a','├','s','┤','┼'))) within group(order by xl)
end a from
(select x.l xl,y.l yl from
t x,t y)n,m where rn(+)=1 and m.x(+)=xl and m.y(+)=yl
group by yl order by 1;

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
12#
 楼主| 发表于 2016-3-16 10:54 | 只看该作者
peter1166 发表于 2016-3-16 10:24
SELECT LISTAGG(BW,'')WITHIN GROUP(ORDER BY X)
FROM (
SELECT T2.XY, T1.XY ,T2.X, T2.Y

为什么要 CHR(14849212)呢

使用道具 举报

回复
论坛徽章:
41
生肖徽章:鼠
日期:2013-12-06 14:15:45生肖徽章:牛
日期:2013-12-06 14:15:45生肖徽章:虎
日期:2013-12-06 14:15:45生肖徽章:兔
日期:2013-12-06 14:15:45生肖徽章:龙
日期:2013-12-06 14:15:45生肖徽章:蛇
日期:2013-12-06 14:15:45生肖徽章:马
日期:2013-12-06 14:15:45生肖徽章:羊
日期:2013-12-06 14:15:45生肖徽章:猴
日期:2013-12-06 14:15:45生肖徽章:鸡
日期:2013-12-06 14:15:45
13#
发表于 2016-3-16 11:05 | 只看该作者
'┼' 用这个的时候,总报错,ORA-00907: missing right parenthesis
后来改成  CHR(14849212) 就好了,奇怪了。

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
14#
 楼主| 发表于 2016-3-16 11:23 | 只看该作者
本帖最后由 〇〇 于 2016-3-16 11:23 编辑

缩短一点


with mv as(
select l,substr(s,2,1)e,substr(s,-2,1)x,substr(s,-1)y from(
select level l,regexp_substr(moves,';[WB]\[[a-z]{2}',1,level)s from goes connect by level<=REGEXP_COUNT(MOVES,';'))),
m as(select mv.*,row_number()over( partition by x,y order by l desc)rn from mv ),
t as(select chr(96+level) l from dual connect by level<=19)
select yl,
listagg(decode(e,'W','○','B','●',decode(yl,'a' ,decode(xl,'a','┌','s','┐','┬')
                                            ,'s' ,decode(xl,'a','└','s','┘','┴')
,decode(xl,'a','├','s','┤','┼')))) within group(order by xl)
a from
(select x.l xl,y.l yl from
t x,t y)n,m where rn(+)=1 and m.x(+)=xl and m.y(+)=yl
group by yl order by 1;

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
15#
 楼主| 发表于 2016-3-16 13:25 | 只看该作者
peter1166 发表于 2016-3-16 11:05
'┼' 用这个的时候,总报错,ORA-00907: missing right parenthesis
后来改成  CHR(14849212) 就好了,奇怪 ...

我们的字符集不同
select ascii('┼') from dual;

ASCII('┼')
-----------
      43488

使用道具 举报

回复
论坛徽章:
484
ITPUB北京香山2007年会纪念徽章
日期:2007-01-24 14:35:02ITPUB北京九华山庄2008年会纪念徽章
日期:2008-01-21 16:50:24ITPUB北京2009年会纪念徽章
日期:2009-02-09 11:42:452010新春纪念徽章
日期:2010-03-01 11:04:552010数据库技术大会纪念徽章
日期:2010-05-13 10:04:272010系统架构师大会纪念
日期:2010-09-04 13:35:54ITPUB9周年纪念徽章
日期:2010-10-08 09:28:512011新春纪念徽章
日期:2011-02-18 11:43:32ITPUB十周年纪念徽章
日期:2011-11-01 16:19:412012新春纪念徽章
日期:2012-01-04 11:49:54
16#
发表于 2016-3-16 13:45 | 只看该作者
peter1166 发表于 2016-3-16 11:05
'┼' 用这个的时候,总报错,ORA-00907: missing right parenthesis
后来改成  CHR(14849212) 就好了,奇怪 ...

应该是字符集的问题

使用道具 举报

回复
论坛徽章:
41
生肖徽章:鼠
日期:2013-12-06 14:15:45生肖徽章:牛
日期:2013-12-06 14:15:45生肖徽章:虎
日期:2013-12-06 14:15:45生肖徽章:兔
日期:2013-12-06 14:15:45生肖徽章:龙
日期:2013-12-06 14:15:45生肖徽章:蛇
日期:2013-12-06 14:15:45生肖徽章:马
日期:2013-12-06 14:15:45生肖徽章:羊
日期:2013-12-06 14:15:45生肖徽章:猴
日期:2013-12-06 14:15:45生肖徽章:鸡
日期:2013-12-06 14:15:45
17#
发表于 2016-3-16 14:30 | 只看该作者
也出来, 但是反了不行。


select CHR(43488) from dual;

CHR(43488)
----------


SELECT ASCII('┼') FROM DUAL ;

  ASCII('┼')
------------
    14849212
   
SELECT VALUE FROM V$NLS_PARAMETERS
WHERE  PARAMETER = 'NLS_CHARACTERSET';

VALUE
----------------------------------------------------------------
AL32UTF8

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
18#
 楼主| 发表于 2016-3-16 16:14 | 只看该作者
用instr快一些
col a for a40
with mv as(
select l,substr(s,2,1)e,substr(s,-2,1)x,substr(s,-1)y from(
select level l,regexp_substr(moves,';[WB]\[[a-z]{2}',regexp_instr(moves,';[WB]\[[a-z]{2}',1,level))s from goes connect by level<=REGEXP_COUNT(MOVES,';'))),
m as(select mv.*,row_number()over( partition by x,y order by l desc)rn from mv ),
t as(select chr(96+level) l from dual connect by level<=19)
select yl,
listagg(decode(e,'W','○','B','●',decode(yl,'a' ,decode(xl,'a','┌','s','┐','┬')
                                            ,'s' ,decode(xl,'a','└','s','┘','┴')
,decode(xl,'a','├','s','┤','┼')))) within group(order by xl)
a from
(select x.l xl,y.l yl from
t x,t y)n,m where rn(+)=1 and m.x(+)=xl and m.y(+)=yl
group by yl order by 1;

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
19#
 楼主| 发表于 2016-3-16 16:15 | 只看该作者
peter1166 发表于 2016-3-16 14:30
也出来, 但是反了不行。

我的
ZHS16GBK

使用道具 举报

回复
论坛徽章:
407
紫蛋头
日期:2012-05-21 10:19:41迷宫蛋
日期:2012-06-06 16:02:49奥运会纪念徽章:足球
日期:2012-06-29 15:30:06奥运会纪念徽章:排球
日期:2012-07-10 21:24:24鲜花蛋
日期:2012-07-16 15:24:59奥运会纪念徽章:拳击
日期:2012-08-07 10:54:50奥运会纪念徽章:羽毛球
日期:2012-08-21 15:55:33奥运会纪念徽章:蹦床
日期:2012-08-21 21:09:51奥运会纪念徽章:篮球
日期:2012-08-24 10:29:11奥运会纪念徽章:体操
日期:2012-09-07 16:40:00
20#
 楼主| 发表于 2016-3-16 21:37 | 只看该作者
with mv as(
select l,substr(s,2,1)e,substr(s,-2,1)x,substr(s,-1)y from(
select level l,substr(moves,regexp_instr(moves,';[WB]\[[a-z]{2}',1,level),5)s from goes connect by level<=REGEXP_COUNT(MOVES,';'))),
m as(select mv.*,row_number()over( partition by x,y order by l desc)rn from mv ),
t as(select chr(96+level) l from dual connect by level<=19)
select yl,
listagg(decode(e,'W','○','B','●',decode(yl,'a' ,decode(xl,'a','┌','s','┐','┬')
                                            ,'s' ,decode(xl,'a','└','s','┘','┴')
,decode(xl,'a','├','s','┤','┼')))) within group(order by xl)
a from
(select x.l xl,y.l yl from
t x,t y)n,m where rn(+)=1 and m.x(+)=xl and m.y(+)=yl
group by yl order by 1;

使用道具 举报

回复

您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

TOP技术积分榜 社区积分榜 徽章 团队 统计 知识索引树 积分竞拍 文本模式 帮助
  ITPUB首页 | ITPUB论坛 | 数据库技术 | 企业信息化 | 开发技术 | 微软技术 | 软件工程与项目管理 | IBM技术园地 | 行业纵向讨论 | IT招聘 | IT文档
  ChinaUnix | ChinaUnix博客 | ChinaUnix论坛
CopyRight 1999-2011 itpub.net All Right Reserved. 北京盛拓优讯信息技术有限公司版权所有 联系我们 未成年人举报专区 
京ICP备16024965号-8  北京市公安局海淀分局网监中心备案编号:11010802021510 广播电视节目制作经营许可证:编号(京)字第1149号
  
快速回复 返回顶部 返回列表