Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Getting ORA-00933: SQL command not properly ended SELECT CASE WHEN

User_JPX5YMar 22 2022

Trying to get a return of lowest # based on 2 fields. This returns the wrong amount of 3 when 2 need 2 in the check field.
This is my original code that runs but returns the wrong amount.
select location,unitofstorage,depth,
SUM(CASE WHEN depth=pallets then depth else to_char(pallets) end) AS "CHECK"
  FROM db
  WHERE facility IN ('XXX4')
   GROUP BY location,unitofstorage,depth
  ORDER BY location
This is the result. CHECK should be 2.
image.png

Somebody said to try this.... But getting the ORA-00933: SQL command not properly ended. I suspect it is something simple but I have not found anything to help as of yet. I simplified this version.

select a.*,
CASE WHEN a.pallets<=a.depth then to_char(a.pallets) else a.depth end AS "CHECK"
    FROM db
    WHERE (facility IN ('xxx4')
    AND unitofstorage<>'NA')a;

ORA-00933: SQL command not properly ended 00933. 00000 - "SQL command not properly ended" *Cause:
*Action: Error at Line: 1 Column: 354

This post has been answered by Frank Kulash on Mar 23 2022
Jump to Answer
Comments
Post Details
Added on Mar 22 2022
3 comments
6,828 views