| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> SELECT COUNT(CASE WHEN.... question
I cannot find documentation of this behaviour in the Oracle docs and
would appreciate a reference (if there is one). For some reason it
appears that the SELECT statement in a cursor cannot use the "CASE
WHEN" construct.
The first SQL query = okay.
The second SQL query, as a cursor, is syntactically incorrect.
Thank you
Barry
SQL> CREATE TABLE tblTest(a NUMBER,b NUMBER);
Table created.
SQL>
SQL> SELECT a
2 FROM tblTest
3 GROUP BY a
4 HAVING 16=COUNT(CASE WHEN b>46 THEN 1 ELSE NULL END);
no rows selected
SQL> SQL> SQL> DECLARE 2 CURSOR c1 IS 3 SELECT a 4 FROM tblTest 5 GROUP BY a 6 HAVING 16=COUNT(CASE WHEN b>46 THEN 1 ELSE NULL END);7 BEGIN
HAVING 16=COUNT(CASE WHEN b>46 THEN 1 ELSE NULL END);
*
ORA-06550: line 6, column 23: PLS-00103: Encountered the symbol "CASE" when expecting one of the following:
SQL>
SQL> SELECT *
2 FROM V$VERSION;
BANNER
SQL>
SQL>
Received on Fri Dec 05 2003 - 11:14:25 CST
![]() |
![]() |