Skip to content
Advertisement

is there a PRODUCT function like there is a SUM function in Oracle SQL?

I have a coworker looking for this, and I don’t recall ever running into anything like that.

Is there a reasonable technique that would let you simulate it?

SELECT PRODUCT(X)
FROM
(
    SELECT 3 X FROM DUAL
    UNION ALL 
    SELECT 5 X FROM DUAL
    UNION ALL
    SELECT 2 X FROM DUAL
)

would yield 30

Advertisement

Answer

select exp(sum(ln(col)))
  from table;

edit:

if col always > 0

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement