sql case语句sql命令未正确结束错误

时间:2017-03-25 12:21:59

标签: sql oracle

SQL> SELECT CUSTOMER.CUSTOMERID,
  2  BOOKING.EVALUATIONRATING,
  3  EVENT.EVENTID
  4  FROM CUSTOMER
  5  INNER JOIN BOOKING
  6  ON BOOKING.CUSTOMERID = CUSTOMER.CUSTOMERID
  7  INNER JOIN EVENT
  8  ON EVENT.EVENTID=BOOKING.EVENTID
  9  CASE EVALUATIONRATING
 10  WHEN 0 THEN 'TERRIBLE'
 11  WHEN 1 THEN 'BAD'
 12  WHEN 2 THEN 'MEDIOCRE'
 13  WHEN 3 THEN 'FAIR'
 14  ELSE 'GOOD';
CASE EVALUATIONRATING
*
ERROR at line 9:
ORA-00933: SQL command not properly ended

尝试使用连接添加case语句时出错。我想使用案例构造将数字转换为文本。

1 个答案:

答案 0 :(得分:2)

您的end应以select结尾,并且位于查询的SELECT CUSTOMER.CUSTOMERID, BOOKING.EVALUATIONRATING, EVENT.EVENTID, CASE EVALUATIONRATING WHEN 0 THEN 'TERRIBLE' WHEN 1 THEN 'BAD' WHEN 2 THEN 'MEDIOCRE' WHEN 3 THEN 'FAIR' ELSE 'GOOD' END CASE_EVALUATIONRATING FROM CUSTOMER INNER JOIN BOOKING ON BOOKING.CUSTOMERID = CUSTOMER.CUSTOMERID INNER JOIN EVENT ON EVENT.EVENTID=BOOKING.EVENTID; 部分。

location /board {
    proxy_pass http://127.0.0.1:8080/board;
}