• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Query issue

 
Ranch Hand
Posts: 88
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
I know this not the forum for this but still need some idea.

I want to write a query which will return multiplication for of all column value.

For example:

Table
-------------------
A B C
1
2
2
3
1
--------------------
12

this my expected result how to write query for this??
 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oracle doesn't have such an aggregation function.

Assuming your values are always positive, you could employ a little trick:This might introduce inaccuracies, though, due to the ln and exp functions.

Another possibility would be to create the aggregation function yourself. It's not really trivial, though. All the gory details (including the exp(sum(ln(x))) trick) can be found on AskTom.

If I had to create a one-off query returning a product, I'd probably do it in a stored procedure. If it was needed more than, say, three times in the project, I'd probably try to implement the function as described on AskTom.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Martin Vajsar wrote:Assuming your values are always positive, you could employ a little trick:


Nice trick!
 
To avoid criticism do nothing, say nothing, be nothing. -Elbert Hubbard. Please critique this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic