度量快速开发平台-专业、快速的软件定制快开平台

标题: 用sql计算ABCDE*4=EDCBA(这五个数字不重复) [打印本页]

作者: 张兴康    时间: 2020-7-26 14:03
标题: 用sql计算ABCDE*4=EDCBA(这五个数字不重复)
--一个五位数字ABCDE*4=EDCBA,这五个数字不重复
  1. with a as
  2. (select level - 1 as x from dual connect by level <= 10)
  3. select a.x * 10000 + b.x * 1000 + c.x * 100 + d.x * 10 + e.x as y
  4.   from a a, a b, a c, a d, a e
  5. where a.x > 0
  6.    and (a.x * 10000 + b.x * 1000 + c.x * 100 + d.x * 10 + e.x) * 4 =
  7.        e.x * 10000 + d.x * 1000 + c.x * 100 + b.x * 10 + a.x
  8.    and (a.x <> b.x)
  9.    and (a.x <> c.x and b.x <> c.x)
  10.    and (a.x <> d.x and b.x <> d.x and c.x <> d.x)
  11.    and (a.x <> e.x and b.x <> e.x and c.x <> e.x and d.x <> e.x);
复制代码


  1. with t as
  2. (select level-1 as n from dual connect by level <=10)
  3. select * from t a,t b, t c,t d,t e
  4. where to_number(a.n||b.n||c.n||d.n||e.n)*4= to_number(reverse(a.n||b.n||c.n||d.n||e.n)) and a.n<>0
复制代码



作者: 陈晓龙    时间: 2020-7-26 15:38
又整这些高级东西了哦!
作者: 张兴康    时间: 2020-7-28 09:41
万望 发表于 2016-2-28 23:53
我也是说,大牛


作者: 陈晓龙    时间: 2020-7-28 16:07
万望 发表于 2016-2-28 23:53
我也是说,大牛

这娃儿厉害吧!
作者: 万望    时间: 2020-7-28 23:53
陈晓龙 发表于 2016-2-26 15:38
又整这些高级东西了哦!

我也是说,大牛




欢迎光临 度量快速开发平台-专业、快速的软件定制快开平台 (http://bbs.delit.cn/) Powered by Discuz! X3.2