2012-06-05 58 views
1

我有下面的代碼,並且收到錯誤:ORA-00923:FROM關鍵字未找到,其中在所述第四選擇(*)預期。有誰知道爲什麼?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 
+1

'Target_FD_Count'後面有一個逗號,在錯誤位置之前。 – Codo

+0

缺少逗號後的Target_FD_Count – Limey

+0

謝謝,一定要忽略那 –

回答

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, 
+0

謝謝,我一定忽略了這個。 –

1

您在別名Target_FD_Count後缺少逗號。通常,當你發現這個錯誤時,請檢查你選擇的逗號。

相關問題