1

我有下面的代码,我收到错误: ORA-00923: FROM 关键字在第四次选择 ( * )的预期位置未找到。有谁知道为什么?

我搜索了其他帖子并没有找到我的解决方案。

select plan_date as Week,
      plan_date+7 as "Week + 7",
      plan_date+14 as "Week + 14",
      plan_tower, 
      plan_rice_type, 
      plan_hours/100 as Plan_Count,

      (select count(*)
       from smart_rice_cooker rc
       where rc.tower = p.plan_tower and
             rc.rice_type = p.plan_rice_type and
             rc.status <> 'Cancelled' and
             rc.actual_fd_date between p.plan_start_date and p.plan_end_date
      ) as Delivered_FD_Count,

      (select count(*)
       from smart_rice_cooker rc
       where rc.tower = p.plan_tower and
             rc.rice_type = p.plan_rice_type and
             rc.status <> 'Cancelled' and
             rc.actual_fd_date is null and
             rc.target_fd_date between p.plan_start_date and p.plan_end_date
       ) as Target_FD_Count

       ***(select count(*)
       from smart_rice_cooker rc
       where rc.tower = p.plan_tower and
             rc.rice_type = p.plan_rice_type and
             rc.status <> 'Cancelled' and
             rc.actual_td_date between p.plan_start_date+7 and p.plan_end_date+7
      ) as Delivered_TD_Count,

      (select count(*)
       from smart_rice_cooker rc
       where rc.tower = p.plan_tower and
             rc.rice_type = p.plan_rice_type and
             rc.status <> 'Cancelled' and
             rc.actual_rt_date between p.plan_start_date+14 and p.plan_end_date+14
      ) as RT_Delivered_Count,

      (select count(*)
       from smart_rice_cooker rc
       where rc.tower = p.plan_tower and
             rc.rice_type = p.plan_rice_type and
             rc.status <> 'Cancelled' and
             rc.actual_rt_date is null and
             rc.target_rt_date between p.plan_start_date+14 and p.plan_end_date+14
       ) as RT_Target_Count

from smart_plan p
order by plan_tower, plan_rice_type, plan_date
4

2 回答 2

4

后面没有逗号as Target_FD_Count。您需要在此处添加逗号。

(select count(*)
   from smart_rice_cooker rc
   where rc.tower = p.plan_tower and
         rc.rice_type = p.plan_rice_type and
         rc.status <> 'Cancelled' and
         rc.actual_fd_date is null and
         rc.target_fd_date between p.plan_start_date and p.plan_end_date
   ) as Target_FD_Count, -- <-- Comma here

   (select count(*)
   from smart_rice_cooker rc
   where rc.tower = p.plan_tower and
         rc.rice_type = p.plan_rice_type and
         rc.status <> 'Cancelled' and
         rc.actual_td_date between p.plan_start_date+7 and p.plan_end_date+7
  ) as Delivered_TD_Count,
于 2012-06-05T13:31:46.460 回答
1

您在别名 Target_FD_Count 后缺少逗号。通常,当您发现此错误时,请检查您选择的逗号。

于 2012-06-05T13:32:26.567 回答