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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
热搜: 部件 流程 SQL
查看: 2752|回复: 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;
复制代码


回复 支持 反对

使用道具 举报

348

主题

3572

帖子

9741

积分

论坛元老

Rank: 8Rank: 8

积分
9741
板凳
发表于 2020-5-1 17:11:54 | 只看该作者
(*@ο@*) 哇~这个有点复杂啊,我来拆了慢慢看
若現在就覺得失望無力,未來那麽遠妳該怎麽扛...
————————————————————————致自己
回复 支持 反对

使用道具 举报

198

主题

1313

帖子

3806

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
3806
地板
发表于 2020-5-1 18:29:19 | 只看该作者
不错不错,这个sql魅力大。
回复 支持 反对

使用道具 举报

78

主题

634

帖子

1598

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1598
5#
发表于 2020-5-2 08:49:01 | 只看该作者
有点意思。
回复

使用道具 举报

328

主题

3738

帖子

8566

积分

作者

Rank: 7Rank: 7Rank: 7

积分
8566
QQ
6#
发表于 2020-5-2 14:17:10 | 只看该作者
朕试了,确实很屌!
回复 支持 反对

使用道具 举报

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
7#
 楼主| 发表于 2020-5-2 16:00:13 | 只看该作者
陈晓龙 发表于 2015-12-2 14:17
朕试了,确实很屌!


点评

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

使用道具 举报

328

主题

3738

帖子

8566

积分

作者

Rank: 7Rank: 7Rank: 7

积分
8566
QQ
8#
发表于 2020-5-2 18:00:01 | 只看该作者

写这个的娃儿,智商肯定黑高!

点评

属于需要我们膜拜的大神  详情 回复 发表于 2020-5-3 15:05
回复 支持 反对

使用道具 举报

542

主题

5916

帖子

1万

积分

作者

Rank: 7Rank: 7Rank: 7

积分
13589
9#
 楼主| 发表于 2020-5-3 15:05:02 | 只看该作者
陈晓龙 发表于 2015-12-2 18:00
写这个的娃儿,智商肯定黑高!

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

使用道具 举报

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

本版积分规则

手机版|小黑屋|玉祥公司客服-玉祥集团客服  本站关键词:快速开发平台

GMT+8, 2024-5-18 05:55 , Processed in 0.158184 second(s), 33 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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