All possible combinations of a column as applied to a unique entry?

i am having trouble getting a loop to do what i want, if you
can help me find out what i am doing wrong i would appreciate it:
i have a database with 3 tables in it
table 1 has a list of documents - each one having a primary
key
table 2 has a list of document properties, i will call them
property A, B, and C - each one having a primary key
table 3 is a "relational" table that has a column for a
document's PK and a property's PK that that document has
Example of table 3:
docPK / propPK
1 (Document 1) / 1 (A)
2 (Document 2) / 1 (B)
3 (Document 3) / 2 (B)
1 (Document 1) / 2 (B)
1 (Document 1) / 3 (C)
i need to create a loop in ColdFusion that spits out the
number of possible combinations that exist for each document
so the correct output should look like:
Property A
Document 1
Property B
Document 1
Document 2
Document 3
Property C
Document 3
Property A, Property B
Document 1
Proberty A, Property B, Property C
Document 1
this output displays all possible combinations of properties
under the conditions of existing documents
here is the loop i have so far that does not seem to be
working for me,
<cfoutput query="rsProperties">
<ul>
<cfloop from="0" to="# of properties per document"
index="i">
<li>
<cfoutput group="propPK">
<cfif i EQ "# of properties per document">
[#Trim(propertyName)#]
</cfif>
</cfoutput>
</li>
<ul>
<cfoutput group="docPK">
<li><a href="">#Document
Name#</a></li>
</cfoutput>
</ul>
</cfloop>
</ul>
</cfoutput>
my loop returns possible combinations, but it is not
returning ALL possible combinations, for example it may only return
Property A as a single instead of also returning singles Property B
and C
my query simply consists of a SELECT * FROM [the database]
WHERE [the three tables are set equal (as a join)] AND WHERE
[documents exist]
i know this is all rather confusing but if you can help me
make sense of it i will be grateful
thanks for your time

Read the cfoutput section of the cfml reference manual. If
you don't have one, the internet does.
Look for the example that shows you how to use the group
attribute.

Similar Messages

  • All possible combinations of 23 columns in a table.

    Hi,
    We have a table as follows;
    CREATE TABLE ALL_PROD_COMB_TMP
    HDLM_ID NUMBER(10),
    MULTIPATH_ID NUMBER(10),
    TRUE_COPY_ID NUMBER(10),
    UVM_ID NUMBER(10),
    TUNING_ID NUMBER(10),
    CLUSTER_ID NUMBER(10),
    MIDDLEWARE_ID NUMBER(10),
    TAPE_ID NUMBER(10),
    THIRD_PARTY_ID NUMBER(10),
    NAS_ID NUMBER(10),
    HBA_ID NUMBER(10),
    BCM_ID NUMBER(10),
    VOLUME_MIGRATION_VERSION_ID NUMBER(10),
    TIERED_STO_MGR_VERSION_ID NUMBER(10),
    HDPS_ID NUMBER(10),
    SERVER_ID NUMBER(10),
    OS_ID NUMBER(10),
    DWDM_ID NUMBER(10),
    EXTENDER_ID NUMBER(10),
    SWITCH_ID NUMBER(10),
    INTERFACE_ID NUMBER(10),
    HUR_ID NUMBER(10),
    STORAGE_FAMILY_ID NUMBER(10)
    The data in the table is as follows;
    For formatting purpose the table data is shown in transposed form.
    Serial No. Column Name Data Value
    1     HDLM_ID                    377     586               
    2     MULTIPATH_ID               142     357               
    3     TRUE_COPY_ID               1     87     12          
    4     UVM_ID                    89     79               
    5     TUNING_ID               10     9     8          
    6     CLUSTER_ID               3     327     638          
    7     MIDDLEWARE_ID                         
    8     TAPE_ID                    3     47     54          
    9     THIRD_PARTY_ID               3                    
    10     NAS_ID                    12     91     1          
    11     HBA_ID                    300     400               
    12     BCM_ID                    14                    
    13     VOLUME_MIGRATION_VERSION_ID     13     12               
    14     TIERED_STO_MGR_VERSION_ID     1     2               
    15     HDPS_ID                    10     100               
    16     SERVER_ID               3     4               
    17     OS_ID                    2     7               
    18     DWDM_ID                    1                    
    19     EXTENDER_ID               520                    
    20     SWITCH_ID               4                    
    21     INTERFACE_ID               2     1     3     4     
    22     HUR_ID                    2     1     3     4     5
    23     STORAGE_FAMILY_ID          2
    Now we have another table named ALL_PROD_COMB having the same structure as that of ALL_PROD_COMB_TMP. In this ALL_PROD_COMB we need all the possible combinations of all the column values from ALL_PROD_COMB_TMP.
    We tried the following thing;
    insert into
         all_prod_comb (
         hdlm_id           
                                       ,multipath_id           
                                       ,true_copy_id           
                                       ,uvm_id                
                                       ,tuning_id           
                                       ,cluster_id           
                                       ,middleware_id
                                       ,tape_id
                                       ,third_party_id
                                       ,nas_id
                                       ,hba_id
                                       ,bcm_id
                                       ,volume_migration_version_id
                                       ,tiered_sto_mgr_version_id
                                       ,hdps_id
                                       ,server_id
                                       ,os_id                
                                       ,dwdm_id           
                                       ,extender_id           
                                       ,switch_id           
                                       ,interface_id           
                                       ,hur_id                
                                       ,storage_family_id
    select distinct
         a.hdlm_id           
                   ,b.multipath_id           
                   ,c.true_copy_id           
                   ,d.uvm_id                
                   ,e.tuning_id           
                   ,f.cluster_id           
                   ,g.middleware_id
                   ,h.tape_id
                   ,i.third_party_id
                   ,j.nas_id
                   ,k.hba_id
                   ,l.bcm_id
                   ,m.volume_migration_version_id
                   ,n.tiered_sto_mgr_version_id
                   ,o.hdps_id
                   ,p.server_id
                   ,q.os_id                
                   ,r.dwdm_id           
                   ,s.extender_id           
                   ,t.switch_id           
                   ,u.interface_id           
                   ,v.hur_id                
                   ,w.storage_family_id
         from (select hdlm_id from all_prod_comb_tmp) a
    ,(select multipath_id from all_prod_comb_tmp) b
    ,(select true_copy_id from all_prod_comb_tmp) c
                   ,(select uvm_id from all_prod_comb_tmp) d
                   ,(select tuning_id from all_prod_comb_tmp) e
                   ,(select cluster_id from all_prod_comb_tmp) f
                   ,(select middleware_id from all_prod_comb_tmp) g
                   ,(select tape_id from all_prod_comb_tmp) h
                   ,(select third_party_id from all_prod_comb_tmp) i
                   ,(select nas_id from all_prod_comb_tmp) j
                   ,(select hba_id from all_prod_comb_tmp) k
                   ,(select bcm_id from all_prod_comb_tmp) l
                   ,(select volume_migration_version_id from all_prod_comb_tmp) m
                   ,(select tiered_sto_mgr_version_id from all_prod_comb_tmp) n
                   ,(select hdps_id from all_prod_comb_tmp) o
                   ,(select server_id from all_prod_comb_tmp) p
                   ,(select os_id from all_prod_comb_tmp) q
                   ,(select dwdm_id from all_prod_comb_tmp) r
                   ,(select extender_id from all_prod_comb_tmp) s
                   ,(select switch_id from all_prod_comb_tmp) t
                   ,(select interface_id from all_prod_comb_tmp) u
                   ,(select hur_id from all_prod_comb_tmp) v
                   ,(select storage_family_id from all_prod_comb_tmp) w;
    But after looking at the explain plan we had to discard this. Simply not possible. Please help us with some other feasible solution.
    regards,
    Dipankar Kushari.

    Hi,
    That's what I have written while posting. Cartesian is no way possible. But is there any way so that I can find out all possible combination of the following values which is there in a table.
    1 HDLM_ID 377 586
    2 MULTIPATH_ID 142 357
    3 TRUE_COPY_ID 1 87 12
    4 UVM_ID 89 79
    5 TUNING_ID 10 9 8
    6 CLUSTER_ID 3 327 638
    7 MIDDLEWARE_ID
    8 TAPE_ID 3 47 54
    9 THIRD_PARTY_ID 3
    10 NAS_ID 12 91 1
    11 HBA_ID 300 400
    12 BCM_ID 14
    13 VOLUME_MIGRATION_VERSION_ID 13 12
    14 TIERED_STO_MGR_VERSION_ID 1 2
    15 HDPS_ID 10 100
    16 SERVER_ID 3 4
    17 OS_ID 2 7
    18 DWDM_ID 1
    19 EXTENDER_ID 520
    20 SWITCH_ID 4
    21 INTERFACE_ID 2 1 3 4
    22 HUR_ID 2 1 3 4 5
    23 STORAGE_FAMILY_ID 2
    regards,
    Dipankar.

  • Fill Array with all possible combinations of 0/1

    Hi,
    i'm looking for a fast way to fill an array, respectively an int[8], with all possible combinations of 0 and 1 (or -1 and 1, shouldn't make a difference).
    I kind of know how to do it using multiple loops but I assume there is a more elegant or at leaster "better" practice.
    Thanks,
    nikolaus
            static int cnt = 0;
         public static void main(String[] args) {
              int[] element = new int[]{1,1,1,1,1,1,1,1};
              Integer[] x = new Integer[2];
              x[0] = 1;
              x[1] = -1;
              for(int i7:x){
                   element[7] = i7;
                   for(int i6:x){
                        element[6] = i6;
                        for(int i5:x){
                             element[5] = i5;
                             for(int i4:x){
                                  element[4] = i4;
                                  for(int i3:x){
                                       element[3] = i3;
                                       for(int i2:x){
                                            element[2] = i2;
                                            for(int i1:x){
                                                 element[1] = i1;
                                                 for(int i0:x){
                                                      element[0] = i0;
                                                      cnt++;
              }Edited by: NikolausO on Oct 30, 2008 4:21 AM
    Edited by: NikolausO on Oct 30, 2008 4:22 AM

    pm_kirkham wrote:
    No I replied to message number 5. as the ' (In reply to #5 )' above my post indicates, which was in reply to (a reply) to Sabre150's post which wasn't using enhanced loops, nor has any obvious place where you could use that approach to fill the array.
    Though you could pass in an array of the values to fill the array with, and loop over those, instead of using 0 or 1, at which point Sabre's approach becomes the same as your OP, but without the manual unrolling:
    import java.util.Arrays;
    public class NaryCombinations {
    public interface CombinationHandler {
    void apply (int[] combination) ;
    public static void main(String[] args) {
    calculateCombinations(new int[]{-1, 0, 1}, 4, new CombinationHandler () {
    public void apply (int[] combination) {
    System.out.println(Arrays.toString(combination));
    public static void calculateCombinations (int[] values, int depth, CombinationHandler handler) {
    recursivelyCalculateCombinations(values, 0, depth, handler, new int[depth]);
    private static void recursivelyCalculateCombinations (int[] values, int index, int depth,
    CombinationHandler handler, int[] combination) {
    if (index == depth) {
    handler.apply(combination);
    } else {
    for (int value : values) {
    combination[index] = value;
    recursivelyCalculateCombinations(values, index + 1, depth, handler, combination);
    Which looks to use the same basic approach to the generalization I created shortly after posting the original.
    public class Scratch1
         * A 'callback' to be invoked with every combination
         * of the result.
        public interface Callback
             * Invoked for each combination.
             * <br>
             * Each call is passed an new instance of the array.
             * @param array the array containing a combination.
            void processArray(int[] array);
        public Scratch1(final int[] array, final Callback callback, final int... values)
            if (callback == null)
                throw new IllegalArgumentException("The 'callback' cannot be 'null'");
            if (array.length < 1)
                throw new IllegalArgumentException("The array length must be >= 1");
            if ((values == null) || (values.length < 1))
                throw new IllegalArgumentException("The 'values' must have be at least of length 2");
            callback_ = callback;
            values_ = values.clone();
            array_ = array;
        public Scratch1(final int order, final Callback callback, final int... values)
            this(new int[order], callback, values);
         * Generates every possible value and invokes the callback for each one.
        public void process()
            process(0);
         * Internal method with no logical external use.
        private void process(int n)
            if (n == array_.length)
                callback_.processArray(array_.clone());
            else
                for (int v : values_)
                    array_[n] = v;
                    process(n + 1);
        private final Callback callback_;
        private final int[] values_;
        private final int[] array_;
        public static void main(String[] args) throws Exception
            final Callback callback = new Callback()
                public void processArray(int[] array)
                    System.out.println(java.util.Arrays.toString(array));
            new Scratch1(6, callback, 2, 1, 0).process();

  • Generating all possible combinations question

    i'm trying to generate all possible combinations for several single column tables each with one string column.
    so - if table 1 has values (aa, ab, ac)
    table 2 has values (zz, zx)
    table 3 has values (qw, qe)
    the result set would contain all possible combinations:
    aa, ab, ac, zz, zx, qw, qe, aazz, aazx, aaqw, aaqe, aazzqw, aazzqe, aazxqw, aazxqe...etc.
    I've tried cross joins - but that does not get the smaller combinations.
    I've looked at some code examples but they seem to be focused on single letter or number combinations.
    I need to do this using tsql.
    code examples or links to such would be of much help.
    Thanks.

    Something like this might work:
    with t1 as (
    select val from table1
    union all
    select ''
    ), t2 as (
    select val from table2
    union all
    select ''
    , t3 as (
    Select val from table3
    union all
    select ''
    select t1.val + t2.val + t3.val
    from t1 cross join t2 cross join t3
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Printing all possible combinations of a given word.

    Well I'm supposed to print all possible combinations of a given word(I'm writing this for the benefit of those who might not have guessed this from the subject). I've got some code but its horribly wrong. Could anyone point out any mistakes.
    public class Try
        public void display(String s)
            char ch[]=s.toCharArray();
            for(int i=0;i<ch.length;i++)
                String word="";
                word+=ch;
    char c[]=new char[s.length()];
    for(int j=0;j<ch.length;j++)
    if(ch[j]!=ch[i])
    c[j]=ch[j];
    for(int j=0;j<ch.length;j++)
    for(int k=0;k<ch.length;k++)
    if(c[j]!=c[k])
    word+=c[k];
    word+=c[j];
    System.out.println(word);

    Me and Lucifer have been workin on this program for ages.... we cant quite understand your pseudo code.. could you elaborate a bit more on how it works ??
    Meanwhile this is the dysfunctional program weve managed to come up with so far:
    public class SHAM
        public void display(String s)
            char c[]=s.toCharArray();
            for(int i=0;i<c.length;i++)
                String word="";
                char c1[]=new char[c.length-1];
                int a=0;
                for(int l=0;l<c.length;l++)
                    if(i!=l)
                        c1[a++]=c[l];
                for(int j=0;j<c.length-1;j++)
                    char c2[]=c1;
                    word=c[i]+word;
                    if(j+1!=c.length)
                        char t=c2[j];
                        c2[j]=c2[c2.length-1];
                        c2[c2.length-1]=t;
                    for(int k=0;k<c2.length;k++)
                        word+=c2[k];
                    System.out.println(word);               
    }And this is my coding of your pseudo code:
    public class WordCombo2
        public void combo(String s)
            getCombos(s.toCharArray(), s.length());
        private void getCombos(char[] c,int n)
            if (n==1)
                print(c);
                System.out.println();
            else
                for (int i=0;i<c.length;i++)
                    if (i==0 && i<n)
                        c=c[n-1];
    n--;
    getCombos(c,n);
    c[i]=c[n-1];
    private void print(char c[])
    for (int i=0;i<c.length;i++)
    System.out.print(c[i]+" ");
    I really dont understand how this is supposed to work so i dont know whats wrong :( Im sorry this program is just totally baffling me, and on top of that recursion kind of confuses me.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Creating a tree of all possible combinations of {a,b,c,d}

    I am an MSc conversion student who is struggling with the initial stages of coding his Association Rule Mining dissertation project.
    I have a TreeNode class, which is in the process of being written.
    The class is designed to create a tree that stores all possible combinations of a Vector alphabet of strings {a,b,c,d}
    Please could somebody explain what my TreeNode class is doing so far?
    I have had a lot of help with this and I can't understand why there are so many vectors and what they all do.
    A few pointers (no sarcastic comments please) would be much appreciated.
    The code so far:
    package treenode;
    import java.io.*;
    import java.util.*;
    public class TreeNode
    public static final String INFO_TEXT ="A program to store a vector of string items a,b,c,d in all their possible combinations into a TreeNode class";
    private Vector alphabet;
    private Vector data; // this IS TreeRootData
    private Vector children;
    public TreeNode(Vector inputAlphabet, Vector inputData)
    // the alphabet and data have already been parsed in.
    this.alphabet = inputAlphabet;
    this.data = inputData;
    System.out.println("Tree node constructed with data "+displayVectorOfStrings(this.data));
    children = new Vector(); // we now construct the Vector of children
    //createChildren();
    public void createChildren()
    if data.length =
    // first check to see whether the current data length is the same
    // as the length of the alphabet
    // if it is then stop here (return;)
    // we loop through the alphabet we have...
    // for each candidate in the alphabet, attempt to create a new child TreeNode
    // with a data Vector that is the same as the data in this TreeNode plus
    // the candidate we are looking at in the alphabet. i.e. add available LHS
    // NB: Do NOT add if the candidate is already in the data. {a,b,a} is wrong!
    // NB: We will check to see whether data is already in the tree at a later stage
    // NB: The new Child TreeNode MUST BE ADDED to the children VECTOR -
    // or it will be lost
    public static String displayVectorOfStrings(Vector vector) //Printing the Vector of Strings
    String vectorText = "{";
    for (int i=0; i<vector.size(); i++)
    vectorText += (String)vector.elementAt(i)+",";
    if (vector.size() > 0) vectorText = vectorText.substring(0, vectorText.length()-1);
    // now we chop off the last element, replacing it with a closing bracket,
    // provided that the Vector is not empty.
    vectorText += "}";
    return vectorText;
    public static void main(String[] args) //main method WITH THE ARGUMENTS PASSED IN.
    // This main class can be thought of as OUTSIDE the TreeNode class. Although
    // it is in the file called TreeNode.java it is only here for convenience.
    // This is the top level of the program where everything starts. It is here -
    // that the alphabet is hardcoded in and that the Tree root is constructed.
    displayHeading();
    Vector alphabet = new Vector(); // constructing an initial alphabet,
    alphabet.addElement("a"); // which will eventually come from the database
    alphabet.addElement("b");
    alphabet.addElement("c");
    alphabet.addElement("d");
    System.out.println("Alphabet set to be "+TreeNode.displayVectorOfStrings(alphabet));
    // the root's initial data is now made into an empty Vector...
    Vector initialData = new Vector();
    // the root can now be constructed
    TreeNode treeRoot = new TreeNode(alphabet, initialData); // the treeRoot constructor
    public static void displayHeading()
    System.out.println();
    System.out.println(INFO_TEXT);

    I don't remember from which site I took this material.
    You read this to find all possible combination of a set {a,b,c,d}
    Consider three elements A, B, and C. It turns out that for n distinct elements there are n! permutations possible. For these three elements all of the possible permutations are listed below:
    ABC, ACB, BAC, BCA, CAB, CBA
    Since there are 3 elements there are 3! = 6 permutations possible.
    Suppose instead of A, B, and C you have a deck of 52 playing cards. There are 52! permutations possible (i.e., the number of different ways the cards could be shuffled). Since 52! = 8x10^67, you will need to play a lot of cards before you have seen every permutation of the deck! Since shuffling the deck is a random process (or it should be), each of these 52! permutations is equally likely to occur.
    Developing a non-recursive algorithm to generate all permutations of n elements is a non-trivial task. However, developing a recursive algorithm to do this requires only modest effort and this is what we will do next.
    1. Let E = {e1, e2, ..., en } denote the set of n elements whose permutations we are to generate.
    2. Let Ei be the set obtained by removing element i from E.
    3. Let perm(X) denoted the permutations of the elements in the set X.
    4. Let ei.perm(X) denote the permutation list obtained by prefixing each permutation in perm(X) with element ei.
    Consider the following example, which is provided to clarify the definitions given above:
    If E = {a, b, c}, then E1 = {b, c} since the element in position 1 has been removed from E to create E1. Perm(E1) = (bc, cb) since these are the only two possible permutations of the two elements which appear in E1. Finally, e1.perm(E1) = (abc, acb) which should be apparent from the value of e1 and perm(E1) since the element a is simply used as a prefix to each permutation in perm(E1).
    Given these definitions, we set the recursion base case when n = 1. Since only one permutation is possible for one element, perm(E) = (e) where e is the lone element in E. When n > 1, perm(E) is the list e1.perm(E1) followed by e2.perm(E2) followed by e3.perm(E3) � followed by en.perm(En). This recursive definition of perm(E) defines perm(E) in terms of n perm(X)s, each of which involves an X with n � 1 elements. Thus both the base component and the recursive component (of a recursive algorithm) have been established and we thus have a complete recursive technique to generate the permutations.
    The following Java method is an implementation of this recursive definition of perm(E). This method will output all permutations whose prefix is list[0:k-1] and whose suffixes are the permutations of list[k:m]. By invoking the method with Perm(list, 0, n-1) all n! permutations of list[0: n-1] will be produced. [This is because this invocation will set k = 0 and m = n � 1, so the prefix of the generated permutations is null and their suffixes are the permutations of list[0: n-1]. When k = m, there is only one suffix which is list[m] and list[0: m] defines a permutation that is to be produced. When k < m, the else clause is executed.
    In the algorithm, let E denote the elements in list[k: m] and let Ei be the set obtained by removing ei = list[i] from E. The first swapping sequence in the for-loop has the effect of setting list[k] = ei and list[k+1: m] = Ei. Therefore, next statement which is the call to perm computes ei.perm(Ei). The final swapping sequence restores list[k: m] to its state prior to the first swapping sequence (the state is was in before the recursive call occurred).
    public static void perm(Object [] list, int k, int m)
    {    //generate all permutations of list[k:m]
    int i; Object temp;
    if (k == m) //list has one permutation � so output it
    {      for (i = 0; i <= m; i++)
    System.out.print(list);
    System.out.println;
    else //list has more than one permutation � so generate them recursively
    for (i = k; i <= m; i++)
    {     temp = list[k]; //these next three lines are a simple swap function
    list[k] = list[i];
    list[i] = temp;
    perm(list, k+1, m); //the recursive call
    temp = list[k]; //reset the order in the list
    list[k] = list[i];
    list[i] = temp;
    }//end for-loop
    } //end method perm
    See the program pasted below that prints all possible combination of a set {a,b,c,d}
    public class Perm
    public Perm()
    public static void main(String[] args)
    String s = "abcd";
    char [] chars = s.toCharArray();
    perm(chars, 0);
    public static void perm(char [] list, final int k)
    int i;
    char temp;
    if (k == list.length-1) //list has one permutation, so output it
    for (i = 0; i <= list.length-1; i++)
    System.out.print(list[i]);
    System.out.println();
    else { //list has more than one permutation, so generate them recursively
    for (i = k; i <= list.length-1; i++)
    temp = list[k]; //these next three lines are a simple swap function
    list[k] = list[i];
    list[i] = temp;
    perm(list, k+1); //the recursive call
    temp = list[k]; //reset the order in the list
    list[k] = list[i];
    list[i] = temp;
    }//end for-loop

  • Help with oracle sql to get all possible combinations in a table.

    Hello guys I have a small predicatement that has me a bit stumped. I have a table like the following.(This is a sample of my real table. I use this to explain since the original table has sensitive data.)
    CREATE TABLE TEST01(
    TUID VARCHAR2(50),
    FUND VARCHAR2(50),
    ORG  VARCHAR2(50));
    Insert into TEST01 (TUID,FUND,ORG) values ('9102416AB','1XXXXX','6XXXXX');
    Insert into TEST01 (TUID,FUND,ORG) values ('9102416CC','100000','67130');
    Insert into TEST01 (TUID,FUND,ORG) values ('955542224','1500XX','67150');
    Insert into TEST01 (TUID,FUND,ORG) values ('915522211','1000XX','67XXX');
    Insert into TEST01 (TUID,FUND,ORG) values ('566653456','xxxxxx','xxxxx');
    "TUID"                        "FUND"                        "ORG"                        
    "9102416AB"                   "1XXXXX"                      "6XXXXX"                     
    "9102416CC"                   "100000"                      "67130"                      
    "955542224"                   "1500XX"                      "67150"                      
    "915522211"                   "1000XX"                      "67XXX"                      
    "566653456"                   "xxxxxx"                      "xxxxx"                       The "X"'s are wild card elements*( I inherit this and i cannot change the table format)* i would like to make a query like the following
    select tuid from test01 where fund= '100000' and org= '67130'however what i really like to do is retrieve any records that have have those segements in them including 'X's
    in other words the expected output here would be
    "TUID"                        "FUND"                        "ORG"                        
    "9102416AB"                   "1XXXXX"                      "6XXXXX"                     
    "9102416CC"                   "100000"                      "67130"                      
    "915522211"                   "1000XX"                      "67XXX"                      
    "566653456"                   "xxxxxx"                      "xxxxx"  i have started to write a massive sql statement that would have like 12 like statement in it since i would have to compare the org and fund every possible way.
    This is where im headed. but im wondering if there is a better way.
    select * from test02
    where fund = '100000' and org = '67130'
    or fund like '1%' and org like '6%'
    or fund like '1%' and org like '67%'
    or fund like '1%' and org like '671%'
    or fund like '1%' and org like '6713%'
    or fund like '1%' and org like '67130'
    or fund like '10%' and org like '6%'...etc
    /*seems like there should be a better way..*/can anyone give me a hand coming up with this sql statement...

    mlov83 wrote:
    if i run this
    select tuid,fund, org
    from   test01
    where '100000' like translate(fund, 'xX','%%') and '67130' like translate(org, 'xX','%%');this is what i get
    "TUID"                        "FUND"                        "ORG"                        
    "9102416AB"                   "1XXXXX"                      "6XXXXX"                     
    "9102416CC"                   "100000"                      "67130"                      
    "915522211"                   "1000XX"                      "67XXX"                      
    "566653456"                   "xxxxxx"                      "xxxxx"                      
    "9148859fff"                  "1XXXXXX"                     "X6XXX"                       the last item should be excluded. The second digit in "org" is a "7" Fund is wrong, too. You're looking for 6 characters ('100000'), but fund on that row is 7 characters ('1XXXXXX').
    and this is sitll getting picked up.That's why you should use the _ wild-card, instead of %
    select  tuid, fund, org
    from    test01
    where  '100000' like translate (fund, 'xX', '__')
    and    '67130'  like translate (org,  'xX', '__')
    ;It's hard to see, but, in both calls to TRANSLATE, the 3rd argument is a string of 2 '_'s.

  • Possible combination of coins

    Hello, I'm just new here. I have some algorithm problem with algorithm that couldn't put it to a code. The problem is "For a given denomination of money (5, 10, 20, 50, 100), get all possible combinations that will not exceed 2000 and at least one of them is present".
    I know this is easy for others but for me, it's quite difficult. I already searched but I can't find something that is similar with this problem.
    Here's what I tried,
    Given:
    denominations = { 5, 10, 20, 50, 100};
    total = 2000;
    A=5, B=10, C=20, D=50, E=100
    A' = counts of A // A' >= 1
    B' = counts of B // B' >= 1
    C' = counts of C // C' >= 1
    D' = counts of D // D' >= 1
    E' = counts of E // E' >= 1
    A A' + BB' + C*C' + D*D' + E*E' <= total
    The problem is I can't find a way for a possible counts of the denomination.
    Any help is much appreciated.
    Thanks.

    For a brute force approach, consider a simpler problem:
    Can you solve the problem if denominations = {5} and maxValue = 1820?
    For each solution of the problem the above case, does it generate a smaller problem to be solved for the next higher denomination in {5, 10, 20, 50, 100}?
    Can you see how to get a solution to the bigger problem from the smaller ones?
    If you've done data structures in your course, you may also want to make it more efficient by memotisation so you don't recompute the combinations of 20,50,100 given 10 = 2 * 5 etc.

  • Show all the possible combinations of n elements in an array???

    If I have an array of n elements, how to show all the possible combinations of n elements.
    What is the java library for doing the combinations??
    For example,
    public class CombinationTest
    {     public static void main(String[] args)     
         {     ArrayList letters = new ArrayList();
              leters.add("s1");
              leters.add("s2");
              leters.add("s3");
    Find all the combinations of 3 elements: C(3,2). Here's the result:
    1) s1, s2
    2) s1, s3
    3) s2, s3
    }

    There isn't a built-in API method for this. Still, combinations are pretty easy. Pseudocode (borrowing notation from ML and GJ, and assuming immutable sets): Set<Set<Object>> getCombinations(int itemsInCombo, Set<Object> itemsToCombine)
        // Handle base case and exceptional cases
        if (itemsInCombo = 0) return Set.emptySet();
        if (itemsInCombo < 0) throw new Exception("?!");
        // Recursive case
        Object o = itemsToCombine.first(); // use iterator - may throw exception
        // Get combos with first element
        Set<Set<Object>> rv = map (x => x.add(o)) getCombinations(itemsInCombo - 1, itemsToCombine.remove(o));
        // Add combos without first element
        rv.add(getCombinations(itemsInCombo, itemsToCombine.remove(o)));
        return rv;
    }

  • Easiest way to sum all possible (different) combinations in an array?

    Hey guys, 
    Say I have an array of sorted values (of attenuation), I want to generate an array of all possible sums of those values, sort it, then refer to it as a list of all possible attenuation values (lets say theyre bits on a discrete digital attenuator).  I will try to show you an example of what I mean with letters:
    Array of attens: [a, b, c, d]
    I want an array like this: [a+b,  a+c,  a+d,  a+b+c,  a+b+d,  a+c+d,  b+c,  b+d,  b+c+d]... I hope I'm not missing any combos here...
    I'm attaching my attempt at this idea but there's something missing I think, I am doing something wrong...
    Thanks for any ideas or help.
    Solved!
    Go to Solution.
    Attachments:
    Sum all possible combos.vi ‏18 KB

    Ben wrote:
    The challenge is getting all possible combos.
    Have you concidered looking at this as a variation on binary counting?
    The total number of combinations is 2^(NumberOfSettings) if you include "None".
    So generate a ramp from zero to the total number possible.
    Convert each number to a boolean array and then use the boolean to determine if its corresponding value gets add into the total.
    After processing all of the values from the ramp the final array should be in ascending order.
    I hope that outline helps,
    Ben
    Ben, that is actually quite brilliantly simple.  I like it.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Update all rows in a View Column via one Apex Form field

    Appreciate any helpful answers to this query.
    I have an Apex App (4.x) where I have a view: PRICE_MODEL_CRA_V
    In the view, I have the following applicable columns:
    COUNTRY
    GRADE
    SALARY
    In the form I have the following fields
    :P16_COUNTRY (DROPDOWN)
    :P16_GRADE (DROPDOWN)
    :P16_SALARY (Number)
    In my app, I have a form with an Update button. I am simply trying to get Apex to update all rows in the salaray column in the view, where the country and grade match.
    I've the following code for the Update button:
    UPDATE PRICE_MODEL_CRA_V
    SET SALARY = :P16_SALARY
    WHERE COUNTRY = :P16_COUNTRY
    AND GRADE = :P16_GRADE
    The option I have chosen in condition type is:
    Value of Item / Column expression is NOT Null (as there are values in the column)
    Also tried SQL Expression and it does not like..says that there is No Expression.
    Thanks again if anyone can help :)

    Hi,
    Sorry I realize now that piece of information was not well supported.
    If I choose SQL Expression for Condition Type in my Form Page and I try to Apply Changes
    Apex says this..
    •Failed to parse SQL query!
    ORA-00936: missing expression
    I was assuming that I need to have the colon for the items in the form where I am wanting Apex to grab the values entered by the user. I tried them without the colons with the SQL Expression condition and same result.
    UPDATE PRICE_MODEL_CRA_V
    SET SALARY = P16_SALARY
    WHERE COUNTRY = P16_COUNTRY
    AND GRADE = P16_GRADE
    I did put 1-1/0 in my expression field and applied changes and then tried ot submit the form and it does not produce an error, so perhaps it is not being called? Where would I start with troubleshooting that?
    Thanks,

  • Most efficient way to code all possible combos?

    Hi everyone,
    I'm in the process of creating a unit conversion utility using the Swing GUI interface package. Basically there are 2 drop down menus: one for the starting unit, and the other for the unit that the first unit will be converted to. Whenever someone chooses an item on either of the menus, the index or menu selection number is loaded into a variable. What my problem is is that I'm trying to write code for every possible unit conversion. For instance, menu item 1 must be able to be converted to every item on menu 2.
    Here is a sample of what I mean:
    if (menuOneItem == 0 && menuTwoItem == 0)
       output = input;
    if (menuOneItem == 0 && menuTwoItem == 1)
       output = input * 0.032808398950131;//Centimeters/sec� to Feet/sec�
    if (menuOneItem == 0 && menuTwoItem == 2)
       output = input * 0.39370078740157;//Centimeters/sec� to Inches/sec�And on and on untill menuTwoItem reaches something like 10. Now I have to do the next item of menu one and code all the combos with the others for it:
    if (menuOneItem == 1 && menuTwoItem == 0)
       output = input * 30.48;//Feet/sec� to Centimeters/sec�
    if (menuOneItem == 1 && menuTwoItem == 1)
       output = input;
    if (menuOneItem == 1 && menuTwoItem == 2)
       output = input * 12.0;//Feet/sec� to Inches/sec�Do you see what I'm trying to do? You have to realize that I have many other different unit conversions like distance and mass. The time it would take to implement all the combinations would be ridiculous! There must be a better way to program in all the different types of conversions like this.
    Any help anyone can offer me will be greatly appreciated! Thanks!

    One way (not necessarily very object-oriented) would be:
    final static double [][] conversionFactors = new double[MENU_ONE_SIZE][MENU_TWO_SIZE];
    // fill out the array somehow--could be in a static initializer
    double getConversionFactor(int menuOne, int menuTwo)
       if (menuOne <= menuTwo)
           return conversionFactors[menuOne][menuTwo];
       else
           return 1.0/conversionFactors[menuTwo][menuOne];
    }You'd only fill in the array where index1 <= index2.
    So:
    [0, 0] = 1.0; //no conversion
    [0, 1] = 0.032808398950131;
    [0, 2] = 0.39370078740157;
    ... through to end.
    Then
    getConversionFactor(0, 1) = 0.032808398950131;The opposite:
    getConversionFactor(1, 0) = 1.0/0.032808398950131 = 30.48;You could enter all conversion factors, if you want. You could also put in a minimal number of hardcoded constants, and calculate the rest as products of multiple known values:
    cm/feet = (cm/inches )*(inches/feet);

  • How to find max audio peak of combined audio tracks with effects applied?

    Hello all,
    I am working in PPro CS5.5.
    Often when I am working on a timeline I have two audio tracks of the same songs, one from the camera and one from a separate sound recorder, synced on the timeline so they combine into one signal. Applied to these tracks I might have an E.Q. effect or highpass/lowpass filter. Now I know that the max peak of each track or individual clips is easy to find using the 'Audio Gain' menu item, what I am hoping for is the equivalent of that menu item but related to the final output after the two tracks signal has been added together and effects have been all been applied? It is a very laborious task to have to listen through the whole timeline to discover if the output is going over 0db, if there was a way I could locate on the timeline where the max output is, that would definitely solve the problem.
    Finding the way to do this would save literally hours per project! It's the one thing that makes me inwardly groan when I have to effect the output volume, which I have to do most of the time.
    Hopefully,
    Peter.

    I have found audio to be more difficult to learn than video. Audio has so much more subtlety, where perceptions don't always equate to what seems obvious. With multiple tracks adding together things get very complex very fast and peak amplitude has very little relationship to volume. When you compress a waveform the volume can be increased! Who'd have thunk it? Then you have S/N ratios and harmonics, soft clipping and hard clipping... Which brings me to the option on the Dynamics Effect called Soft Clip that is a smoother kind of limiter.
    It's amazing where a simple one line suggestion can lead you; having worked a bit more with the dynamics 'effect' I am deciding that I like it a lot. The automation is not absolute but it broadens the tolerances I can work within. Very liberating!

  • Precalculate all characteristics combinations of a BW query...

    Hi All,
      We need precalculate all possible characteristics combinations (drill downs) of a query to fill the BW cache.
      Looking on the Reporting Agent it´s possible precalculate a bw query using another query to control the filters, however using this feature it is not possible to pass all the possible navigations steps of the query to the variant.
    Anyone can help me with this issue?
    Enrique.

    Enrique,
    Welcome to SDN...
    What you need to do for the same is :
    Have all the characteristiics in the rows areas and then run the query in the background using reporting agent , this will fill up the OLAP cache and you can use the same.
    All the data resides in the cache and you can use the original query later and it would fetch the records from the cache.
    To check the same , activate the cache first
    Then run the fully detailed query
    Now run any other version of the query through BeX and then check in SM04 to see if you are fetching the records directly from the cube/ods or from the cache ( indicated by RSRCACHE)
    Arun
    Assign points if useful

  • How do you combine a stacked column chart with a clustered column chart

    Hello,
    I am trying to combine a stacked column chart with a clustered column chart. I know that in Excel there is a way to trick that described on the next site: http://people.stfx.ca/bliengme/ExcelTips/Columns.htm
    Is that possible with BI Publisher?
    Thank you very much!
    Codruta Crisan

    Finally I get it myself:
    You need to use graph type as BAR_VERT_STACK2Y and the declare the series that you want to see on the first Y vertical bar as assignedToY2="false" and the ones that you wanr to see on the second Y vertical bar as assignedToY2="true".
    In my case I use 4 Series, 2 stack on the first clustured column and 2 stacked on the second (2Y) clustured colum....see below
    graphType="BAR_VERT_STACK2Y">
    <SeriesItems>
    <Series id="0" assignedToY2="false" color="#BBD6E7"/>
    <Series id="1" assignedToY2="false"/>
    <Series id="2" assignedToY2="true" color="#004A96"/>
    <Series id="3" assignedToY2="true"/>
    </SeriesItems>

Maybe you are looking for

  • IMac multiple monitors VGA Switch

    Hi. I have an iMac 20" early January 2006, a 32inch Samsung LCD TV with PC Input and a 17 inch external monitor. I wish to use both the TV and external monitor as a secondary monitor for my iMac. Obviously not at the same time. Would I be able to use

  • How to Debug a ABAP code running the background in Portal

    How can I debug a ABAP code running in the background while executing a transaction code through portal. e.g Presently I have to incorporate some checks in the portal. For that I know the function module where i need to put though checks. Now I want

  • How do they choose which ebook to put on the featured list

    My book is up on iTunes. It is very high quality. Howl do they choose which ones to have on the Featured list as opposed to merely the release date category.  Also... What about DRM.? What's the difference and does this accept their decision?

  • Magnifying glass instead of res. change / sidescrolling in Opera

    1) when using the thinkvantage Fn+Space the screen resolution goes down. Is it possible, to start the magnifying glass instead of resolution changing? 2) I tried a few tutorials using sidescrolling with Opera, but was not successfull.  Sidescrolling

  • Waiting to download Local files onto smartphone....

    Hi. So all I'm trying to do is add music from my pc onto my spotify and be able to listen to on my Galaxy S5. I've done everything right, followed all the how-to's. The only problem now is that when I attempt to download the music to make it availabl