Hiho,

I've posted this at the cf dev support forums but haven't gotten any 
replies, so I thought I'd try here (where all the really smart people 
are :-)

How would you do this in CF (any version 4.5 or higher): return all
unique combinations of rows where the unique row field value combination
has a certain summed value?

For example:
I have a SocksTable with 6 SockDrawers, and each SockDrawer has a number
of Socks in it. I want to get the list of unique combinations of 
SockDrawers that have a combined total of, say, 6 Socks or less. The 
SocksTable would look something like:

SocksTable
--------------
SockDrawerID
TotalSocks

and data in it would be something like:

SockDrawer ID TotalSocks
---------- -------------
1           5
2           2
3           1
4           3
5           4
6           7

The results would have a query list of the combinations:

1,3
2,3
2,3,4
2,5

I'm really looking for the best performance solution, so it may be that 
the answer is to do the simple select query, then do an escalating loop 
through the results, but if there are more than 6 SockDrawers, I'm 
afraid that it might be quite a performance hit, since each additional 
SockDrawer -- or even increasing the total number of Socks -- would 
exponentially increase the iterations required.
That is, if I had 20 or 50 SockDrawers (yes, a huge SocksTable, but 
maybe I collect socks :-) would seem to be quite onerous and, 
performance-wise, quite a bugger using a loop.

Can anyone here point me in the right direction? I really don't need 
exact code, just possible an idea of how to go about doing this the best 
way.

Thanks in advance!

Tom







~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to