Adam,
What you want looks like something similar to pp. 407-410 in Graeme
Birchall's DB2 SQL Cookbook. I checked in the latest version, for DB2
9.5. That example should work in V5R4 SQL.
For those with earlier editions, it's under Fun with SQL, Other Fun
Things, Transpose Numeric Data.
You can get Graeme's e-book (free) from his website:
http://mysite.verizon.net/Graeme_Birchall/id1.html
HTH,
Loyd
Loyd Goodbar
Business Systems
BorgWarner Shared Services
662-473-5713
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Adam Glauser
Sent: Friday, July 25, 2008 11:38 AM
To: midrange-l@xxxxxxxxxxxx
Subject: Produce set of sets using SQL
Here is a simplified example which outlines the problem. Suppose we
have a table like this:
k1 k2 dest
a a 1
a a 2
a b 3
b c 4
b c 5
b c 6
(k1,k2) constitutes a unique identifier for a load, and each load has
one or more destinations. I would like to end up with ((1,2), (3),
(4,5,6)), that is, a set of all combinations of destinations which have
been stops on the same load. I'd then like to count how many loads have
used a particular combination, but that's probably best as a separate
step.
As an Amazon Associate we earn from qualifying purchases.