【问题标题】:How to convert below MS SQL Server query into Oracle如何将下面的 MS SQL Server 查询转换为 Oracle
【发布时间】:2022-08-18 15:46:55
【问题描述】:
SELECT CASE
           WHEN :pfdate = 1
           THEN
               NULL
           WHEN     :startdtmonth = :fromdatemonth
                AND :startdtyear = :fromdateyear
           THEN
               :startdate
           WHEN :startdate >
                CONVERT (
                    date,
                    dateadd (
                        day,
                          -day (
                               eomonth (
                                   dateadd (month,
                                            -( :period - 1),
                                            :fromdate)))
                        + 1,
                        eomonth (dateadd (month, -( :period - 1), :fromdate))),
                    103)
           THEN
               :startdate
           ELSE
               CONVERT (
                   date,
                   dateadd (
                       day,
                         -day (
                              eomonth (
                                  dateadd (month, -( :period - 1), :fromdate)))
                       + 1,
                       eomonth (dateadd (month, -( :period - 1), :fromdate))),
                   103)
       END    AS fromdate
  FROM DUAL
 WHERE :app_period = \'Months\'
  • 如果您将代码包装在代码显示中,它实际上会有所帮助。 - 谢谢!

标签: oracle


【解决方案1】:
SELECT CASE WHEN :pfdate = 1 THEN NULL WHEN :startdtmonth = :fromdatemonth AND :startdtyear = :fromdateyear THEN :startdate WHEN :startdate > CONVERT ( date, -day * interval '1'  day(5) ( eomonth ( - * interval '1'  month( :period - 1) + :fromdate)) + 1 + eomonth (- * interval '1'  month( :period - 1) + :fromdate), 103) THEN :startdate ELSE CONVERT ( date, -day * interval '1'  day(5) ( eomonth ( - * interval '1'  month( :period - 1) + :fromdate)) + 1 + eomonth (- * interval '1'  month( :period - 1) + :fromdate), 103) END AS fromdate FROM DUAL WHERE :app_period = 'Months'

【讨论】:

    猜你喜欢
    • 2019-03-01
    • 2016-07-29
    • 1970-01-01
    • 2022-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-02
    • 1970-01-01
    相关资源
    最近更新 更多