Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use GROUP BY on a CLOB column with Oracle?

Tags:

People also ask

Can you GROUP BY CLOB?

Sorry, you can't group by a clob: You cannot specify LOB columns in the ORDER BY clause of a query, or in the GROUP BY clause of a query or in an aggregate function.

How does Oracle handle CLOB data types?

In Oracle, you can use LENGTH() or DBMS_LOB. GETLENGTH() function to get the length of a CLOB column in characters. There is LENGTHB() function to get the length in bytes, but it can be used for single-byte CLOBs only, so it will return the same result as LENGTH().

Can we compare CLOB in Oracle?

Unfortunately, Oracle can't perform minus operations on clobs.


I'm trying to combine the GROUP BY function with a MAX in oracle. I read a lot of docs around, try to figure out how to format my request by Oracle always returns:

ORA-00979: "not a group by expression"

Here is my request:

SELECT A.T_ID, B.T, MAX(A.V) 
FROM bdd.LOG A, bdd.T_B B
WHERE B.T_ID = A.T_ID
GROUP BY A.T_ID
HAVING MAX(A.V) < '1.00';

Any tips ?

EDIT It seems to got some tricky part with the datatype of my fields.

  • T_ID is VARCHAR2
  • A.V is VARCHAR2
  • B.T is CLOB