ORA-00936:缺少表情?

问题描述 投票:0回答:2

试图找出为什么这不起作用

sql oracle decode ora-00936
2个回答
3
投票

由于在解码语句中使用< > =导致问题,请改用:

SELECT a.account_id "Account ID",
   a.first_name ||' '|| a.last_name "Name",
   b.date_and_time_created "Date Created",
   c.date_and_time_ordered "Date Ordered",
   c.date_and_time_ordered - b.date_and_time_created "Days Ordered After Created",
   (case when ( c.date_and_time_ordered - b.date_and_time_created  <  5 ) then 'No Reminder Needed'
         when ( c.date_and_time_ordered - b.date_and_time_created  >= 5 ) then 'Reminder Needed'
         else ' '
     end ) "Reminder"
FROM shopper a 
   JOIN shopping_cart b ON a.account_id = b.shopper_account_id
   JOIN orders c ON a.account_id = c.shopper_account_id

1
投票

或者,如果你坚持使用DECODE(虽然,我不知道你为什么要这样做,因为CASE在这里更合适),你可以使用SIGN功能,例如

SELECT DECODE (
          SIGN ( (c.date_and_time_ordered - b.date_and_time_created) - 5),
          -1, 'less than 5',
          'greater than or equal to 5')
          result
  FROM ...
© www.soinside.com 2019 - 2024. All rights reserved.