473,407 Members | 2,629 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Computing the product of a column groupped by...

I need your help here :

I need to compute the product of a column, with conditions, over a
table, grouped by a key (it is a probability table).

In fact I need the exact equivalent of :

select key1, key2, sum( val )
from "sometable"
where "some parameterized condition"
group by key1, key2

*except* that I want the *multiplication* of all "val" instead of the sum.

I'd like the output to behave as much as a table column aggregative
function as possible, it is used in other queries.

In Oracle I'd solve this by using pipelined table functions, in DB2 I'm
lost, since table functions can only return the result of a select.

Can anyone help me ?

Am I stuck with using a procedure storing large results sets in a
temporary table with all the concurrency problems that this causes ?

Using DB2 for windows / UNIX 8.1.2.

Thanks in advance for any suggestion.

Mar 28 '06 #1
3 1421
My two ideas.
1) EXP(SUM(LOG(val)))
But, this returns floating point number. So, exact value could not be
received.

2) Use recursive query. (and common table expression, if you want
combine with other data)

Mar 28 '06 #2

"Tonkuma" <to*****@jp.ibm.com> a écrit dans le message de news:
11**********************@g10g2000cwb.googlegroups. com...
My two ideas.
1) EXP(SUM(LOG(val)))
But, this returns floating point number. So, exact value could not be
received.


Stupid me, I should have thought of this.

I like this idea, I'll check if there is not too much imprecision in the
result, I think it should be OK. It's probabilities anyway.

thanks !
Mar 28 '06 #3
Tonkuma wrote:
My two ideas.
1) EXP(SUM(LOG(val)))
But, this returns floating point number. So, exact value could not be
received.

2) Use recursive query. (and common table expression, if you want
combine with other data)


Another alternative is to roll your own aggregates. But this is not
trivial: http://tinyurl.com/7z49y and for groupings:
http://tinyurl.com/b2rq5

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Joan MacEachern | last post by:
Join Sun's Chief Strategy Officer, Mark Tolliver on Wednesday, December 3, 2003 at 8 am PST for Sun's Network Computing O3-Q4 Event. This event's focus includes product releases that will help you...
2
by: Josué Maldonado | last post by:
Hello list, I have a table called pedh that looks like this: REFNO FECHA OCNUM PVD 0199 10/12/2003 5224 632 0199 10/12/2003 5224 632 1264 10/18/2003 8991 210 1264 10/18/2003 8991 210...
4
by: Web_PDE_Eric | last post by:
I don't know where to go, or what to buy, so plz re-direct me if I'm in the wrong place. I want to do high performance integration of partial differential eqns in n dimensions (n=0,1,2,3..etc) I...
0
by: natty2006 | last post by:
Submission Deadline extended: 13 November 2006 ************************************************************* IADIS INTERNATIONAL CONFERENCE APPLIED COMPUTING 2007 February 17-20, 2007 -...
13
by: Xah Lee | last post by:
Today, a motherfucker Christophe Rhodes (aka Xof in irc://chat.freenode.net/lisp ) kicked banned me. Here's the few relevant excerpt. (full, unedited excerpt will be published if there is a public...
14
by: Aaron Watters | last post by:
So, in between skiing runs I noticed a Business Week cover story on "cloud computing". The article had lots of interesting information in it like about how somebody's mom used to be an airline...
0
by: nityaprashant | last post by:
Hello.. could u plz help me? i have template column inside grid view.. in that one link button called Remove this? when i click on that link button confirmation box like "Are u sure u want...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.