首页-玉祥公司客服

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 部件 流程 SQL
查看: 2921|回复: 8
打印 上一主题 下一主题

[分享] 感受sql语句的魅力

[复制链接]

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
跳转到指定楼层
楼主
发表于 2020-5-1 16:07:15 | 显示全部楼层 |只看大图 回帖奖励 |倒序浏览 |阅读模式

  1. <blockquote>--打印五角星
复制代码
效果图:


再来一个:
  1. --打印出奥运五环
  2. with a as
  3. (select distinct round(a.x + b.x) x, round(a.y + b.y) y
  4.     from (select (sum(x) over(order by n)) x,
  5.                  round(sum(y) over(order by n)) y
  6.             from (select n,
  7.                          cos(n / 30 * 3.1415926) * 2 x,
  8.                          sin(n / 30 * 3.1415926) y
  9.                     from (select rownum - 1 n
  10.                             from all_objects
  11.                            where rownum <= 30 + 30))) a,
  12.          (select n,
  13.                  (sum(x) over(order by n)) x,
  14.                  round(sum(y) over(order by n)) y
  15.             from (select n,
  16.                          cos(m / 3 * 3.1415926) * 2 * 15 x,
  17.                          sin(m / 3 * 3.1415926) * 15 y
  18.                     from (select case
  19.                                    when rownum <= 2 then
  20.                                     3
  21.                                    when rownum = 3 then
  22.                                     -2
  23.                                    else
  24.                                     -6
  25.                                  end m,
  26.                                  rownum - 1 n
  27.                             from all_objects
  28.                            where rownum <= 5))) b)
  29. select replace(sys_connect_by_path(point, '/'), '/', null) star
  30.   from (select b.y, b.x, decode(a.x, null, ' ', '*') point
  31.           from a,
  32.                (select *
  33.                   from (select rownum - 1 + (select min(x) from a) x
  34.                           from all_objects
  35.                          where rownum <= (select max(x) - min(x) + 1 from a)),
  36.                        (select rownum - 1 + (select min(y) from a) y
  37.                           from all_objects
  38.                          where rownum <= (select max(y) - min(y) + 1 from a))) b
  39.          where a.x(+) = b.x
  40.            and a.y(+) = b.y)
  41. where x = (select max(x) from a)
  42. start with x = (select min(x) from a)
  43. connect by y = prior y
  44.        and x = prior x + 1;
复制代码
效果图:



分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
沙发
 楼主| 发表于 2020-5-1 16:10:46 | 显示全部楼层
打印五角星的代码好像看不到,重新发过:
  1. with a as
  2. (select distinct round(sum(x) over(order by n)) x,
  3.                   round(sum(y) over(order by n)) y
  4.     from (select n,
  5.                  cos(trunc(n / 20) * (1 - 1 / 5) * 3.1415926) * 2 x,
  6.                  sin(trunc(n / 20) * (1 - 1 / 5) * 3.1415926) y
  7.             from (select rownum - 1 n from all_objects where rownum <= 20 * 5)))
  8. select replace(sys_connect_by_path(point, '/'), '/', null) star
  9.   from (select b.y, b.x, decode(a.x, null, ' ', '*') point
  10.           from a,
  11.                (select *
  12.                   from (select rownum - 1 + (select min(x) from a) x
  13.                           from all_objects
  14.                          where rownum <= (select max(x) - min(x) + 1 from a)),
  15.                        (select rownum - 1 + (select min(y) from a) y
  16.                           from all_objects
  17.                          where rownum <= (select max(y) - min(y) + 1 from a))) b
  18.          where a.x(+) = b.x
  19.            and a.y(+) = b.y)
  20. where x = (select max(x) from a)
  21. start with x = (select min(x) from a)
  22. connect by y = prior y
  23.        and x = prior x + 1;
复制代码


回复 支持 反对

使用道具 举报

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
板凳
 楼主| 发表于 2020-5-2 16:00:13 | 显示全部楼层
陈晓龙 发表于 2015-12-2 14:17
朕试了,确实很屌!


点评

写这个的娃儿,智商肯定黑高!  详情 回复 发表于 2020-5-2 18:00
回复 支持 反对

使用道具 举报

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
地板
 楼主| 发表于 2020-5-3 15:05:02 | 显示全部楼层
陈晓龙 发表于 2015-12-2 18:00
写这个的娃儿,智商肯定黑高!

属于需要我们膜拜的大神
回复 支持 反对

使用道具 举报

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

本版积分规则

关闭

站长推荐上一条 /1 下一条

手机版|小黑屋|首页-玉祥公司客服  本站关键词:玉祥平台客服

GMT+8, 2024-6-16 02:49 , Processed in 0.126885 second(s), 29 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表