Need help in creating for loop

Hi,
I want to create two different Xquery transformation by checking attribute value in the input xml.
<n:DIAMessage xsi:schemaLocation="http://pearson.com/DIA C:/shashi/rewrite/DIA/DIA_Schemas/DIA_new.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:n="http://pearson.com/DIA">
<n:Customer>
<n:Account sourceClassName="Account" sourceInstanceID="01560900" sourceSystem="MDR">
<n:hasAccountRelation sourceClassName="AccountRelation" sourceInstanceID="01560900" sourceSystem="MDR">
<n:hasAccountPerson name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR"/>
</n:hasAccountRelation>
</n:Account>
<n:Account sourceClassName="Account" sourceInstanceID="01560900" sourceSystem="MDR">
<n:hasAccountRelation sourceClassName="AccountRelation" sourceInstanceID="01560900" sourceSystem="MDR">
<n:hasAccountPerson name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR"/>
</n:hasAccountRelation>
</n:Account>
<n:Person name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
<n:hasIdentifier sourceClassName="Identifier" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
<n:IDType>GENDER</n:IDType>
<n:IDTypeName>GENDER</n:IDTypeName>
<n:IDValue>M</n:IDValue>
</n:hasIdentifier>
</n:Person>
<n:Person name="BRIAN C STRICKLAND" sourceClassName="Person" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
<n:hasIdentifier sourceClassName="Identifier" sourceInstanceID="01560900|$|00114" sourceSystem="MDR">
<n:IDType>GENDER</n:IDType>
<n:IDTypeName>GENDER</n:IDTypeName>
<n:IDValue>M</n:IDValue>
</n:hasIdentifier>
</n:Person>
</n:Customer>
</n:DIAMessage>
From the above Message i need to create two transformation by checking
if (DIAMessage/Customer/Account/@sourceClassName="Account")
then call {
Xquery1
if(DIAMessage/Customer/Person/@sourceClassName="Person")
then call{
Xquery2
Constraint here is Account and Person block occurence will be many times.As they are in same hierarchy how to create a for loop concept here?
Please anyone can help me on this?

Hi,
Create a numeric variable to act as While loop counter and assign value of 1. Create a boolean variable to act as a flag to exit loop and assign value of true.
Create a while object with a condition that while flag variable is true loop.
Then you can create a switch with a case for each of your scenarios, referencing the xth record (defined by loop counter variable) in xml using ora:getElement
When the count of required elements in input xml is less than your loop variable, assign the variable to exit loop as false...otherwise increment counter by one to loop to next record.
Hope this helps.

Similar Messages

  • Need help with a For loop that uses a Break statement

    I need to create a for loop which counts down from 100-50 and divides the number being counted down by a counter. Can anyone help me?
    public class Break
    public static void main ( String args []) (;
         int total = 0
         int counter = 0
         for { (int number = 100; total >=50; total --)
         if (counter == 0)
         break;
         } // end of for loop
         int output = number/counter
         system.out.printf("The number is" %d output/n)
         }// end of method main
    }// end of class Break

    Im sorry I didnt explain myself very well i do not need the break statement at all.
    I now have this code:
    public class BreakTest
       public static void main( String args[] )
          int count; // control variable also used after loop terminates
         for (int i = 100; i >= 50; i = ++count)
       if (i >= 50) {
        continue;
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
       } // end main
    } // end class BreakTest
    /code]
    and i get these error messages:
    F:\csc148>javac BreakTest.java
    BreakTest.java:9: variable count might not have been initialized
         for (int i = 100; i >= 50; i = ++count)
                                          ^
    BreakTest.java:15: variable count might not have been initialized
          System.out.printf( "\nBroke out of loop at count = %d\n", count );
                                                                    ^
    2 errors                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Need help with a for loop

    Hi all
    I have a dir that has a list of folders that are created using php that my customers upload to. the PHP creates a new folder using the system date on the days that they upload. (using this format yyyymmdd)
    What I am trying to do is loop thou the folders and get todays folder and list the files that are in todays folder. I have been able to do this up to the point of if a customer folder does not have a folder called todays date.
    I know I need some sort of try / catch but don't know what.
    Can anyone help me please
    Thanks for you time and help in advance
    Craig
      public void getfolderList() {
        File dir = new File("/Users/craig/Documents/jBuilder_Epod/copy");
        File[] getFolderNames = dir.listFiles();
        if (getFolderNames != null) {
          for (int gf = 0; gf < getFolderNames.length; gf++) {
            String store = "" + getFolderNames[gf];
            if (!store.endsWith(".DS_Store")) { // This is a mac file name Only
              String folderName = "" + getFolderNames[gf];
              if (!store.endsWith(".DS_Store")) { // This is a mac file name Only
                //I need to have some sort of try and Catch here.
                // If there is no Folder called "todaysFileName" I need to go to the next folder
                //i.e. stop the for loop and go to next
                String setTodaysFileName = folderName + "/";
                String todaysFileName = setTodaysFileName + systemDate;
                File todaysFolder = new File(todaysFileName);
                File[] todaysFiles = todaysFolder.listFiles();
                for (int td = 0; td < todaysFiles.length; td++) {
                  todaysFileName = "" + todaysFiles[td];
                  System.out.println("There is no folder Today........" +
                                     todaysFileName);
      }

    A quick guess would be that after the sStatement
      File[] todaysFiles = todaysFolder.listFiles();todaysFiles is null if todaysFolder doesn't exist and you get a NullPointerException when trying to access todaysFiles.length in the following for-loop.
    If that doesn't help, please be a bit more precise what kind of Exception occurs...

  • Need help with the for loop

    Hello,
    I hope someone can point me in the right direction for my next assignment. I am very new at Java programming. For my next assignment for class I will need expand my previous program which was a mortgage calculator. The first assignment we wrote a program to show the monthly payments of a $200,000 loan at 5.75% for 30 years. Now we have to output all 360 monthly payments with pauses in between so it doesnt scoll off the page. The calculation that we use is:
    month_payments = (principle * monthlyinterest) / (1-Math.pow(1 + monthlyinterest, - months));
    My question is how do I get the correct calculation outputed 360 times. I would like to use the "for loop" to do this. Also what is the correct way to do the pause command? I do not want someone to write the code, I just want some help to where I need to start off, I want to learn this on my own.
    Thanks in advance,
    DC

    for (int i ; i < 10 ; i ++ ) { System.out.println("Come sail away"); }
    or;
    int i = 0;
    while(i < 10)
        i++;
        System.out.println("Come sail away");
    }

  • Need help with basic "for" loops!

    Here is my prompt for class:
    Write a program that prompts the user to enter a sentence from the keyboard using JOptionPane.showInputDialog.
    The program will print the characters back with the first letter of each word changed from lower case into upper case. If you have a capital letter in the original line and it is not the first letter of a word, then this letter should be switched from upper case to lower case. The only capital letters that should appear in the line must be the beginning letter of every word in the line. All other characters will remain the same.
    I figured everything out except for one part. How do I make the first letter of each word change from lower case into uppercase? How do I switch a letter that is uppercase in the middle of a word to lowercase? Last but not least, how do I make sure that the only capital letters in the sentence are the first letter of each word?
    I need to do this using for Loops, charAt(), and if/else statements because this is just an intro class. I just can't figure this last part out! Help please!

    String words = ...;
    StringBuilder builder = new StringBuilder();
    for (int i = 0; i < words.length; i++) {
    char c = words.charAt(i);
    boolean isUpper = Character.?(look up the methods in java.lang.Character)
    boolean isLetter = ? (there are actually 2 ways to do this. Hint: you can use <= and >= and && to solve this)
    if (!isLetter) {
    continue;
    } else {
    // check if this is the start of the word. How do you know that you are at the start of a word?
    if (!isUpper && isStartOfTheWord) c = Character.toUpperCase(c); //Hint: there is a way you can do this with x + y
    else if (isUpper) //make c lower case
    builder.append(c);
    return builder.toString();

  • I need help with my for loop in this array

    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    import javax.swing.JOptionPane;
    public class Runner
        public static void main (String[] args)
            String timeStr;
            int time, again, optiStr;
            Inbound[] in = new Inbound[25];
             in[0]=new Inbound ("",0,"On Time num0");
             in[1]=new Inbound ("",2,"On Time num1");
             in[2]=new Inbound ("",3,"Delayed num2");
             in[3]=new Inbound ("",4,"On Time");
             in[4]=new Inbound ("",5,"On Time");
             in[5]=new Inbound ("",6,"Canceled");
             in[6]=new Inbound ("",1,"Canceled num6");
             in[7]=new Inbound ("",8,"On Time");
             in[8]=new Inbound ("",9,"Delayed");
             in[9]=new Inbound ("",10,"On Time");
             in[10]=new Inbound ("",11,"Delayed");
             in[11]=new Inbound ("",12,"On Time");
             in[12]=new Inbound ("",13,"Delayed");
             in[13]=new Inbound ("",14,"On Time");
             in[14]=new Inbound ("",15,"On Time");
             in[15]=new Inbound ("",16,"On Time");
             in[16]=new Inbound ("",17,"Canceled");
             in[17]=new Inbound ("",18,"On Time");
             in[18]=new Inbound ("",19,"On Time");
             in[19]=new Inbound ("",20,"Canceled");
             in[20]=new Inbound ("",21,"On Time");
             in[21]=new Inbound ("",22,"Delayed");
             in[22]=new Inbound ("",23,"On Time");
             in[23]=new Inbound ("",24,"Cancled");
             in[24]=new Inbound ("",7,"On Time num24");
            do{
                timeStr = JOptionPane.showInputDialog ("In military time, what hour do you want?");
                time = Integer.parseInt(timeStr);
                if (time<=0 || time>24)
                 JOptionPane.showMessageDialog (null, "Error");
                 optiStr = JOptionPane.showConfirmDialog (null, "If you want Incoming flights click Yes, but if not click No");
                if (optiStr==JOptionPane.YES_OPTION)
    //(ok this is the for loop i am talking about )
                    for (int index = 0; index < in.length; index++)
                      if ( time == Inbound.getTime())
                   JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    //               else JOptionPane.showMessageDialog (null, "else");
                }//temp return else if failed to find time asked for
    //             else
    //               if (optiStr==JOptionPane.CANCEL_OPTION)
    //                 JOptionPane.showMessageDialog(null,"Canceled");
    //              else
    //                {Outbound.run();
    //                JOptionPane.showMessageDialog (null, "outbound");}//temp
                  again=JOptionPane.showConfirmDialog(null, "Try again?");
            while (again==JOptionPane.YES_OPTION);
    }any help would be greatly appriciated.

    rumble14 wrote:
    Ok well, I can't get my code to work. Also, please remember that this is just my draft so it isnt pretty. I will fix it up later so please look at it. The thing I want to do is look into the array for a time that matches what the user entered and return the toString() of that one. I know there is something wrong with my for loop but I cant figure how to fix it. please help. here is what i have so far:
    >//(ok this is the for loop i am talking about )
    for (int index = 0; index < in.length; index++)
    if ( time == Inbound.getTime())
    JOptionPane.showMessageDialog (null, Inbound.tostring());  //return the time asked for
    Inbound.getTime() is a static method of your Inbound class, that always returns the same value, I presume? As opposed to each of the 25 members of your array in, which have individual values?
    Edited by: darb on Mar 26, 2008 11:12 AM

  • Need help with a for loop - string checking

    I am trying to create a for loop to make sure a user entered string contains only letters but something doesn't take. No errors, but the inner loop of try again doesn't ever come into play. What am I missing please.
         String k = keyboard.nextLine();
         for (int i = 0; i < k.length(); i++)
              char c = k.charAt(i);
              int m = c; 
              if (((m < 97) && (m > 122)) || ((m < 65) && (m > 90)))
                        System.out.print("Try again please: ");
                        k = keyboard.nextLine();
    System.out.println(k);

    molested,
    (you and BigDaddyLoveHandles should get on well)
    I would use regular expression for that... which would look something like this...
    // get response containing at least one letter.
    while (true) {
      String response = keyboard.nextLine();
      if( response.matches("[a-zA-Z]+") ) break;
      System.out.print("Try again please: ");
    }Message was edited by: corlettk - frog got the {                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Need help with a for loop please

    Hello,
    I want to do the following:
    double V[][] = sphere.V2;
    double polygon[][][] = {
         { V[0], V[1], V[2] },
    { V[1], V[2], V[3] },
    { V[2], V[3], V[4] },
    { V[3], V[4], V[5] },
    { V[4], V[5], V[6] },
    { V[124], V[125], V[126] },
    How can I set up a loop to initialize the values of polygon so that I dont have to type it all out?
    Thanx a lot
    -Big_Goon

    Any suggestions?
    -Big_Goon

  • Need Help to create new screen for RF Sapconsole

    Hi Guru's
    I'm new on RF (but some years in ABAP) since last week.
    I need help to create new screens for RF (SAPLLMOB).
    Can someone explain me the procedure to create screen (with ABAP code after) or perhaps someone have an exemple (simple or not) ?
    I have to develop 2 new screens with really few time.
    And, another subsidiary question :
    how SAP can transfert information between the flash gun and the screen i have developped.
    Is there some code to add to enable this functionality or it is include in SAPLLMOB on standard fields ????
    It's a new strange world for me today...
    Many thanks to everyone who can explain me
    Alain

    hi,
    I am facing this problem as well. Is there any reference to create the new screen?
    Hope someone can help! Thanks!
    Regards,
    Darren

  • I need help with Creating Key Pairs

    Hello,
    I need help with Creating Key Pairs, I generate key pais with aba provider, but the keys generated are not base 64.
    the class is :
    import java.io.*;
    import java.math.BigInteger;
    import java.security.*;
    import java.security.spec.*;
    import java.security.interfaces.*;
    import javax.crypto.*;
    import javax.crypto.spec.*;
    import au.net.aba.crypto.provider.ABAProvider;
    class CreateKeyPairs {
    private static KeyPair keyPair;
    private static KeyPairGenerator pairGenerator;
    private static PrivateKey privateKey;
    private static PublicKey publicKey;
    public static void main(String[] args) throws Exception {
    if (args.length != 2) {
    System.out.println("Usage: java CreateKeyParis public_key_file_name privete_key_file_name");
    return;
    createKeys();
    saveKey(args[0],publicKey);
    saveKey(args[1],privateKey);
    private static void createKeys() throws Exception {
    Security.addProvider(new ABAProvider());
    pairGenerator = KeyPairGenerator.getInstance("RSA","ABA");
    pairGenerator.initialize(1024, new SecureRandom());
    keyPair = pairGenerator.generateKeyPair();
    privateKey = keyPair.getPrivate();
    publicKey = keyPair.getPublic();
    private synchronized static void saveKey(String filename,PrivateKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream(new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    private synchronized static void saveKey(String filename,PublicKey key) throws Exception {
    ObjectOutputStream out= new ObjectOutputStream( new FileOutputStream(filename));
    out.writeObject(key);
    out.close();
    the public key is:
    �� sr com.sun.rsajca.JSA_RSAPublicKeyrC��� xr com.sun.rsajca.JS_PublicKey~5< ~��% L thePublicKeyt Lcom/sun/rsasign/p;xpsr com.sun.rsasign.anm����9�[ [ at [B[ bq ~ xr com.sun.rsasign.p��(!g�� L at Ljava/lang/String;[ bt [Ljava/lang/String;xr com.sun.rsasign.c�"dyU�|  xpt Javaur [Ljava.lang.String;��V��{G  xp   q ~ ur [B���T�  xp   ��ccR}o���[!#I����lo������
    ����^"`8�|���Z>������&
    d ����"B��
    ^5���a����jw9�����D���D�)�*3/h��7�|��I�d�$�4f�8_�|���yuq ~
    How i can generated the key pairs in base 64 or binary????
    Thanxs for help me
    Luis Navarro Nu�ez
    Santiago.
    Chile.
    South America.

    I don't use ABA but BouncyCastle
    this could help you :
    try
    java.security.Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
    java.security.KeyPairGenerator kg = java.security.KeyPairGenerator.getInstance("RSA","BC");
    java.security.KeyPair kp = kg.generateKeyPair();
    java.security.Key pub = kp.getPublic();
    java.security.Key pri = kp.getPrivate();
    System.out.println("pub: " + pub);
    System.out.println("pri: " + pri);
    byte[] pub_e = pub.getEncoded();
    byte[] pri_e = pri.getEncoded();
    java.io.PrintWriter o;
    java.io.DataInputStream i;
    java.io.File f;
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pub64"));
    o.println(new sun.misc.BASE64Encoder().encode(pub_e));
    o.close();
    o = new java.io.PrintWriter(new java.io.FileOutputStream("d:/pri64"));
    o.println(new sun.misc.BASE64Encoder().encode(pri_e));
    o.close();
    java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("d:/pub64"));
    StringBuffer keyBase64 = new StringBuffer();
    String line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] pubBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    br = new java.io.BufferedReader(new java.io.FileReader("d:/pri64"));
    keyBase64 = new StringBuffer();
    line = br.readLine ();
    while(line != null)
    keyBase64.append (line);
    line = br.readLine ();
    byte [] priBytes = new sun.misc.BASE64Decoder().decodeBuffer(keyBase64.toString ());
    java.security.KeyFactory kf = java.security.KeyFactory.getInstance("RSA","BC");
    java.security.Key pubKey = kf.generatePublic(new java.security.spec.X509EncodedKeySpec(pubBytes));
    System.out.println("pub: " + pubKey);
    java.security.Key priKey = kf.generatePrivate(new java.security.spec.PKCS8EncodedKeySpec(priBytes));
    System.out.println("pri: " + priKey);
    catch(Exception e)
    e.printStackTrace ();
    }

  • Need help in creating Buttons in ADF10g

    Hi,
    My questions are:
    1. Is it possible to modify the width of row in ADF10g. Because the width of rows in my output are high. So I want to reduce it.
    2. I need help in creating a new 'createbutton' to create a newlist for the table . for this I have used create button but didnot succed.
    3. I also need help in creating 'save button' to save modified data into the table.
    4. I need help in creating a select-one-choice and select-one-list for columns of table.
    Please help me.
    regards,
    sanjana
    sanjana

    the Easy Tabs could be useful for your requirement
    http://usermanagedsolutions.com/SharePoint-User-Toolkit/Pages/Easy-Tabs-v5.aspx
    /blog
    twttr @esjord

  • Need help in creating tabbed webpart in sharepoint + no of tabs in webpart should be dynamic.

    Need help in creating tabbed webpart in sharepoint and no of tabs in webpart should be dynamic.
    under each tab i should be able to add multiple webparts(each tab will have webpart zone)
    programatically i need to generate tabs and insert webpart zones under each tab.
    Let me  know how can i achieve this.
    i followed below article.
    http://msdn.microsoft.com/en-us/library/jj573263%28v=office.14%29.aspx
    but in this article the tabs and webparts are static and we need to close each webpart .
    Kindly let me know the approach.thanks in advance

    the Easy Tabs could be useful for your requirement
    http://usermanagedsolutions.com/SharePoint-User-Toolkit/Pages/Easy-Tabs-v5.aspx
    /blog
    twttr @esjord

  • Need help with animation, for my XAML game

    Hello friends,
    I need help in creating animation for my snake and ladder game(C#,XAML). I have completed the game logic, but can't understand how to animate my UI.
    1. I want to animate 6 dice images so that when the player clicks on the Roll Dice Button a shuffle animation will play, and while the animation is playing the user can't click any thing.
    2. I want the player disc to move one step at a time (animation) on the game board.
    Please help me I am new to animation. Kindly give a reply

    Hello,
    I would recommend using
    Storyboards and / or the
    XAML animation library.
    Other resources:
    Storyboarded animations (XAML)
    XAML animation library sample
    I hope this helps,
    James
    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

  • Need help in creating a chart from 3 datasets

    Need help in creating a chart in SSRS from 3 datasets
    Can someone help me in creating a chart from 3 datasets, however datasource is same.

    Thank you Olaf...
    could anyone help me in using union all with the below
     WITH a AS (
    SELECT
    clientid,
    DATEPART(year, row_date) AS 'Year',
    DATEPART(month, row_date) AS 'Month',
        value ,
        CASE metricid WHEN 16 THEN 'FCR' ELSE 'Cases' END AS metric
    FROM XXXXXX AS V
    WHERE metricid IN (16, 11)
    AND row_date BETWEEN '2012-01-01' AND '2014-10-01'
    AND value IS NOT NULL)
    , b AS (
    SELECT     clientid ,
        Year ,
        Month ,
        value AS 'Cases',
        metric 
    FROM a
    WHERE metric = 'cases')
    , c AS (
    SELECT     clientid ,
        Year ,
        Month ,
        value AS 'FCR',
        metric  
    FROM a
    WHERE metric = 'FCR')
    , d AS (
    SELECT b.YEAR, b.MONTH, c.FCR, b.Cases 
    FROM b INNER JOIN c 
    ON c.clientid = b.clientid
    AND c.[YEAR] = b.[year] 
    AND c.[month] = b.[month]
    WHERE c.fcr <> 0 AND b.cases <> 0
    ,E AS (
    SELECT [Year], [Month], SUM(FCR) AS FCR, SUM(Cases) AS Cases
    FROM d
    GROUP BY [Year], [Month])
    select YEAR, MONTH, 
    CASE MONTH 
    WHEN 1 THEN 'Jan'
    WHEN 2 THEN 'Feb'
    WHEN 3 THEN 'Mar'
    WHEN 4 THEN 'Apr'
    WHEN 5 THEN 'May'
    WHEN 6 THEN 'Jun'
    WHEN 7 THEN 'Jul'
    WHEN 8 THEN 'Aug'
    WHEN 9 THEN 'Sep'
    WHEN 10 THEN 'Oct'
    WHEN 11 THEN 'Nov'
    WHEN 12 THEN 'Dec'
    END AS MonthName
    ,e.FCR AS FCRCases
    ,e.Cases AS TotalCases
    ,CASE 
    WHEN [month] IN (11, 12, 1) THEN 1
    WHEN [month] IN (2, 3, 4) THEN 2
    WHEN [month] IN (5, 6, 7) THEN 3
    WHEN [month] IN (8, 9, 10) THEN 4
    END AS 'Quarter'
    --,CONVERT(DECIMAL(18, 2),(e.FCR/e.Cases)*100) AS FCRRaw
    from e
    order by YEAR, MONTH
    **************2nd query*************
    WITH a AS (
    SELECT
    clientid,
    DATEPART(year, row_date) AS 'Year',
    DATEPART(month, row_date) AS 'Month',
        value, 
        CASE metricid WHEN 56 THEN 'numerator' ELSE 'denominator' END AS metric
    FROM XXXXXXX.[Values] AS V
    WHERE metricid IN (56, 10)
    --WHERE metricid IN (11,16)
    AND row_date BETWEEN '2013-10-01' AND '2014-02-01'
    AND value IS NOT NULL)
    , b AS (
    SELECT     clientid ,
        Year ,
        Month ,
        value AS 'numerator',
        metric
    FROM a
    WHERE metric = 'numerator')
    , c AS (
    SELECT     clientid ,
        Year ,
        Month ,
        value AS 'denominator',
        metric
    FROM a
    WHERE metric = 'denominator')
    , d AS (
    SELECT b.YEAR, b.MONTH, c.denominator, b.numerator 
    FROM b INNER JOIN c 
    ON c.clientid = b.clientid
    AND c.[YEAR] = b.[year] 
    AND c.[month] = b.[month]
    WHERE c.denominator <> 0 AND b.numerator <> 0
    , e AS (
    SELECT [Year], [Month], SUM(numerator) AS numerator, SUM(denominator) AS denominator
    FROM d
    GROUP BY [Year], [Month]
    SELECT *, 
    CASE 
    WHEN [month] IN (11, 12, 1) THEN 1
    WHEN [month] IN (2, 3, 4) THEN 2
    WHEN [month] IN (5, 6, 7) THEN 3
    WHEN [month] IN (8, 9, 10) THEN 4
    END AS 'Quarter'
    FROM e
    ORDER BY 1,2
    ******************3rd query**************
    WITH a AS (
    SELECT --L.[LocationGroupId],
    -- T.locationid,
    -- T.AccountId,
    TR.datestamp,
    /*Convert(NVARCHAR, DatePArt(year, TR.datestamp)) + '-' + Convert(NVARCHAR, DatePArt(month, TR.datestamp)) + '-01'*/ 
    TR.Period AS ValueDate,
    CASE WHEN TR.TargetResultState = 0 THEN 0 WHEN TR.TargetResultState = 1 THEN 1 WHEN TR.TargetResultState = 2 THEN 1 ELSE 0 END AS Met,
    CASE WHEN CONVERT(DATE, Convert(NVARCHAR, DatePArt(year, TR.datestamp)) + '-' + Convert(NVARCHAR, DatePArt(month, TR.datestamp)) + '-01') > T.Startdate AND CONVERT(DATE, Convert(NVARCHAR, DatePArt(year, TR.datestamp))
    + '-' + Convert(NVARCHAR, DatePArt(month, TR.datestamp)) + '-01') < T.Enddate THEN 1 ELSE 0 END AS ActiveTarget
    FROM XXXXXX AS TR
    INNER JOIN dbo.Target T ON TR.TargetID = T.ID
    --INNER JOIN dbo.Location L ON T.Locationid = L.Id
    WHERE --locationid <> - 1 AND 
    TR.Period IN ('201306', '201307', '201308', '201309', '201310', '201311', '201312', '201401'))
    select ValueDate, SUM(Met) AS Met, Count(ActiveTarget) AS ActiveTargets,
    right(ValueDate,2) as Month
    ,left(ValueDate,4) as Year
    ,CASE 
    WHEN right(ValueDate,2) IN (11, 12, 1) THEN 1
    WHEN right(ValueDate,2) IN (2, 3, 4) THEN 2
    WHEN right(ValueDate,2) IN (5, 6, 7) THEN 3
    WHEN right(ValueDate,2) IN (8, 9, 10) THEN 4
    END AS 'Quarter'
    from a
    group by ValueDate
    order by ValueDate

  • Need help to create report with jpeg/gif image

    Hello,
    I need help with creating a form with a special jpeg/gif seal. I never done this Java. Until now, I created all forms with ansi C++ with HP escape characters to draw lines, boxs, and text. This form will contain boxes which is populated with database information read from a text file.
    Since this form contains a special seal on the upper right, I don't think it can be done with old fashion ansi C++. How can I create a form with Java and create it as a simple exe to just print the form to a specified printer.
    Thanks,
    John

    Hi,
    I am creating a form with boxes (lines and text). What is special about this form is that it has an image jpeg or gif at the top right corner. Is is a state department seal. Up to this form, I had used ansi C++ and print out escape HP character to print out the lines, boxes, and text. I have no idea how to print out the image. I am new to JAVA and only 1 class in it. Is there sample code out there to create this type of form with the image? I need a starting point.
    Thanks,
    John

Maybe you are looking for

  • Interfacing StyledDocument and XML

    Hello, I'm trying to make an xml editor, but am stumped on the javax.swing.text.StyledDocument interface. The problem is that DefaultStyledDocument isn't suited to store xml, and HTMLStyledDocument is well, html. What I want is a document class that

  • Adding new podcasts - not showing up in iTunes music store

    Is there some sort of manual process that must be undertaken when you add a new podcast to your site, to get it to show up in itms? I successfully added my podcast series (had two of them ready to go) and submitted to ITMS. They accepted it, and it s

  • Cost center distribution

    Hi, Kindly Advice how to distribute expenses from one cost center to different cost centers My client was asking for only reporting purpose but amount should not allocate from one cost center to different cost centers For Ex : 20 G/L accounts are cre

  • Open xls files in numbers

    When I get an attachment in my email .xls I cannot open it on my email nor with numbers.  .xlsx is to a problem.   How do I resolve this?

  • Printing CD case inserts

    Recently when using iTunes to print a CD case insert the album artwork just comes out as a black square on both sides. I have used this OK previously (before recent iTunes updates).