0

I am trying to use the following on oracle 11g:

select sum(ora_hash(distinct attribute) from table;

This gives me the error:ORA-00936: "missing expression"

I was expecting this to work, as for example sum(distinct attribute) from table; works fine.

Any advice?

mktz
  • 1
  • 1

1 Answers1

1

This seems like a curious construct. I would recommend either:

 select sum(distinct ora_hash(attribute) from table;

(although sum(distinct) is almost never the right construct.)

Or:

select sum(ora_hash(attribute))
from (select distinct attribute from table) t;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • Thank you Gordon, this worked fine for me. For my context of comparing data content from one datamart to another, sum(distinct) may look weird, but does its job. – mktz May 10 '17 at 08:08