如何优雅的用SQL语言(Oracle版)写春节祝福语!

最后都变了- 提交于 2020-02-01 04:28:58

来源:OAnote-工作笔记
https://www.oanote.com/index.php/archives/34/
 

select sum(t.seq) seq, nvl(t.content, 'By:200') 
  from (select 1 as seq,
               (select decode(substr(to_char(sysdate, 'yyyymm'), 1),
                              '202001',
                              '一言:',
                              (select to_char(sysdate,
                                              'yyyy"年"mm"月"dd"日" hh24:mi:ss')
                                 from dual))
                  from dual) as content
          from dual
        union all
        select 2 as seq,
               (select case
                         when to_number(to_char(sysdate, 'yyyymmdd')) <
                              20200125 and
                              substr(to_char(sysdate, 'yyyymmdd'), 1, 4) =
                              '2020' then
                          (select '提前' || (select to_char(20200125) -
                                                  to_char(sysdate, 'yyyymmdd') ||
                                                  '天祝大佬们新年快乐'
                                             from dual)
                             from dual)
                         when to_number(to_char(sysdate, 'yyyymmdd')) between
                              '20200125' and '20200131' and
                              substr(to_char(sysdate, 'yyyymmdd'), 1, 4) =
                              '2020' then
                          (select '新年快乐,属(shu)你最棒' from dual)
                         when to_char(sysdate, 'yyyymmdd') > '20200131' and
                              substr(to_char(sysdate, 'yyyymmdd'), 1, 4) =
                              '2020' then
                          '工作使我快乐'
                         else
                          '如果不是真的垃圾,谁又甘愿混吃等死一年又一年'
                       end
                  from dual) || '!' content
          from dual) t
 group by cube(t.content)
 order by 1;

来源:OAnote-工作笔记
https://www.oanote.com/index.php/archives/34/

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!