orcale的sql问题

我已经看晕了,各位大佬帮忙看一下

全选.png

关联之后的表

select * from (

                select
                fymonth,
                fdate,
                case substr(c.fmweek,7,1)
                when '1' then '第一周'
                when '2' then '第二周'
                when '3' then '第三周'
                when '4' then '第四周'
                when '5' then '第五周'
                else '第六周' end week
                from new_report.mdm_time  c
left join (
            select  * from(select * from
                select
                number2 ,
                state,
                Subordinate_system,
                department,
                last_week_state,
                task_level ,
                content_task ,
                planned_deliverables ,
                those_responsible ,
                completion_date ,  
                actual_completion_date ,
                task_create_day ,
                this_week_state ,
                remaining_days ,
                task_reply_added ,
                tasks_reporting_day1,
                row_number()  over (partition by number2 order by tasks_reporting_day1 desc) rn
                from NEW_REPORT.TASK_MAINTENANCE) t
                where t.rn<=1  and   t.tasks_reporting_day1 is not null) ) a
on a.tasks_reporting_day = c.fdate) e

表1

select * from (select * from(
    select
        number2 ,
        state,
        Subordinate_system,
        department,
        last_week_state,
        task_level ,
        content_task ,
        planned_deliverables ,
        those_responsible ,
        completion_date ,  
        actual_completion_date ,
        task_create_day ,
        this_week_state ,
        remaining_days ,
        task_reply_added ,
        tasks_reporting_day1,
        row_number()  over (partition by number2 order by tasks_reporting_day1 desc) rn
    from NEW_REPORT.TASK_MAINTENANCE) a
    where a.rn<=1  and   a.tasks_reporting_day1 is not null) b

表2

select * from (
                select
                fymonth,
                fdate,
                case substr(b.fmweek,7,1)
                when '1' then '第一周'
                when '2' then '第二周'
                when '3' then '第三周'
                when '4' then '第四周'
                when '5' then '第五周'
                else '第六周' end week
                from new_report.mdm_time ) c

FineReport 用户kWEye3931 发布于 2020-6-17 17:45 (编辑于 2020-6-18 10:33)
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共3回答
最佳回答
0
fish19880902Lv4初级互助
发布于2020-6-17 18:20(编辑于 2020-6-18 12:38)

image.png

  • 用户kWEye3931 用户kWEye3931(提问者) 我重新上传了sql ,改了半天又成了表名无效了....
    2020-06-18 10:34 
  • fish19880902 fish19880902 回复 用户kWEye3931(提问者) 你后面贴出来的 多了一个括号 最后面a 前面只需要一个括号 where t.rn<=1 and t.tasks_reporting_day1 is not null) ) a
    2020-06-18 11:13 
  • 用户kWEye3931 用户kWEye3931(提问者) 回复 fish19880902 还是一样的报错
    2020-06-18 11:40 
  • 用户kWEye3931 用户kWEye3931(提问者) 回复 fish19880902 嵌套里边的语句正常,嵌套之后就报错了
    2020-06-18 12:05 
  • fish19880902 fish19880902 回复 用户kWEye3931(提问者) 1楼重新贴图发了错误点 你重新看下图片
    2020-06-18 12:38 
最佳回答
0
豆豆小可爱Lv5中级互助
发布于2020-6-17 17:52

left join 的表没有加 别名

image.png

最佳回答
0
Kevin-sLv7中级互助
发布于2020-6-18 11:14(编辑于 2020-6-18 11:15)

用这个就可以了记得采纳:

select * from (


                select

                fymonth,

                fdate,

                case substr(c.fmweek,7,1)

                when '1' then '第一周'

                when '2' then '第二周'

                when '3' then '第三周'

                when '4' then '第四周'

                when '5' then '第五周'

                else '第六周' end week

                from new_report.mdm_time  c

left join (

            select  * from(select * from

                select

                number2 ,

                state,

                Subordinate_system,

                department,

                last_week_state,

                task_level ,

                content_task ,

                planned_deliverables ,

                those_responsible ,

                completion_date ,  

                actual_completion_date ,

                task_create_day ,

                this_week_state ,

                remaining_days ,

                task_reply_added ,

                tasks_reporting_day1,

                row_number()  over (partition by number2 order by tasks_reporting_day1 desc) rn

                from NEW_REPORT.TASK_MAINTENANCE) t

                where t.rn<=1  and   t.tasks_reporting_day1 is not null)  a

on a.tasks_reporting_day = c.fdate

)e


  • 4关注人数
  • 391浏览人数
  • 最后回答于:2020-6-18 12:38
    请选择关闭问题的原因
    确定 取消
    返回顶部