Comparing values in a vector!!

I solved my previous problem, but now i've come across another, it seems my unfamiliarity with vectors aint helping, oh well practice makes perfect. Anyway I've written a method which will iterate through a list of numbers using a vector and delete any duplicate items from the vector. Here's the code
public int deleteMultiple() {
     int i = 0;
     while(i<current_size) {
          int j;
          int k = 0;
          int l = k + 1;
          m = 0;
          for(j = 0; j<current_size; j++) {
            if(data.elementAt(k) == data.elementAt(l)) {
     data.removeElementAt(l);
                m++;
          else {
               l++;
     k++;
     i++;
     return m;
}Sorry about the alignment, it's hard to get right in this thing. I think the problem lies in the if statement I don't think it ever gets into that particular block. Say I had a list comprising of the following numbers
1 2 3 1
Then what the list should look like after deletion is
1 2 3
Any input would be greatly appreciated!!!!

Ok I'm going to post all of the code cos I know I'm really close to solving this problem now.
This code is ListDemo2.java, and this is basically the main progrm thats sets up all the applet stuff and displays the lists. What it can do is insert an item onto the end of the list, make an ordered list from zero up to an input in the text field(integer), make a random list, clear the list, delete duplicates ( this is what i'm having trouble with ) and exit the applet.
import java.awt.*;
import java.awt.event.*;   /* new in 1.1 for EventListener */
import java.applet.Applet;
import java.util.*;
public class ListDemo2 extends Applet implements ActionListener,
                         AdjustmentListener
    private ListByVector list = new ListByVector(0);
    // setup a limit for displaying the list
    final int    numRow = 5;
    final int    numCol = 10;
    final int      maxDisplay = numRow * numCol;
    private int  scrollbarPos = 0;
    private TextField userInput;
    private Label messageLabel;
    private Label scrollbarLabel;
    private Label[] itemLabels;
    private Scrollbar listScroll;
    private Button insertButton;
    private Button mk_olistButton;
    private Button mk_rlistButton;
    private Button clearButton;
    private Button deleteButton;
    private Button exitButton;
    // ... adding more buttons here
    public void init() {
     // 1. define stuff on the first panel - control panel
        Panel controlPanel1 = new Panel();
         userInput = new TextField("", 5);
         insertButton = new Button("insert");
         mk_olistButton = new Button("mk_olist");
     mk_rlistButton = new Button("mk_rlist");
        clearButton = new Button("clear");
     deleteButton = new Button("delete");
         exitButton = new Button("quit");
     controlPanel1.setLayout(new FlowLayout(FlowLayout.LEFT));
     controlPanel1.add(userInput);
     controlPanel1.add(insertButton);
        controlPanel1.add(mk_olistButton);
     controlPanel1.add(mk_rlistButton);
        controlPanel1.add(clearButton);
     controlPanel1.add(deleteButton);
     controlPanel1.add(exitButton);
     // ... adding new buttons
     // for event handling we need these lines
     insertButton.addActionListener(this);
        mk_olistButton.addActionListener(this);
     mk_rlistButton.addActionListener(this);
        clearButton.addActionListener(this);
     deleteButton.addActionListener(this);
     exitButton.addActionListener(this);
     // ... any newly added buttons need the above line
     // 2. define stuff on the second panel - message panel
        Panel controlPanel2 = new Panel();
         messageLabel = new Label("Initially, the list is empty");
         scrollbarLabel = new Label("                          ");
        controlPanel2.setLayout(new GridLayout(2,1));
     controlPanel2.add(messageLabel);
     controlPanel2.add(scrollbarLabel);
     // 3. define stuff on the third panel - list display panel
        Panel listPanel = new Panel();
        Panel listDisplay = new Panel();
     itemLabels = new Label[maxDisplay];
     listDisplay.setLayout(new GridLayout(numRow,numCol));
        int tmp=0;
     for(tmp=0; tmp < maxDisplay; tmp++) {
             itemLabels[tmp] = new Label("          ");
         listDisplay.add(itemLabels[tmp]);
        listScroll =
         new Scrollbar(Scrollbar.VERTICAL,0,0,0,
          list.sizeLimit()/numCol + 1);
     listScroll.addAdjustmentListener(this); /* new in 1.1 */
     listPanel.setLayout(new BorderLayout());
        listPanel.add( "West", listDisplay);
        listPanel.add( "East", listScroll);
        // finally, add the above 3 to the applet
     setLayout(new BorderLayout());
        add("North",  controlPanel1);
        add("Center", controlPanel2);
     add("South", listPanel);
    }   // end of ListDemo's constructor
    public void actionPerformed(ActionEvent event) {
     String     input_buffer;
        int     k;
        // read a string from the text field
     input_buffer = new String(userInput.getText());
        if(event.getSource() == clearButton) {
            list.clearUp();
         showList(list);
            showMessage("list cleared");
     else if(event.getSource() == insertButton) {
         k = list.insertAtEnd(input_buffer);
         if(k>=0) { // inserted OK
                showList(list);
                showMessage(
                    "inserted  " + input_buffer + "  at  " + k);
            else { // reached the limit, nothing inserted
                showMessage("sorry, you cannot insert any more");
        else if(event.getSource() == mk_olistButton) {
            k = list.createOrderedList(input_buffer);
         if(k>0) {
             showList(list);
             showMessage("an ordered list is created, the list size is "+k);
         else showMessage("please input the size of your list");
        else if(event.getSource() == mk_rlistButton) {
            k = list.createRandomList(input_buffer);
            if(k>0) {
                showList(list);
                showMessage("a random list is created, the list size is "+k);
            else showMessage("please input the size of your list");
/*Quick note about the code below, if I keep it as is
with the showList(list) commented out it will not visibly
delete the duplicates but the message that  comes up
saying how many duplicates were deleted gives the
correct answer for the first time only, if I were to create
another random list with a different set of duplicates then
the message will be incorrect. Also if the showList(list)
were to be uncommented then the program suffers from
overflow problems??????*/
        else if(event.getSource() == deleteButton) {
         k = list.deleteMultiple();
     //    showList(list);
         showMessage("deleted " +k + " duplicate items");                    
        else if(event.getSource() == exitButton) {
          System.exit(0);
    public void adjustmentValueChanged(AdjustmentEvent event) {
     if(event.getSource() == listScroll) {
          scrollbarPos = listScroll.getValue();
             showScrollbarMessage(
              "the scrollbar  position  is  " + scrollbarPos);
             showList(list);
    void showList(ListByVector list)
     int     i = scrollbarPos;
        int     n = list.size();
     int     c = 0;
        i = i * numCol;
     while((i < n) && (c < maxDisplay)) {
         itemLabels[c].setVisible(true);
         itemLabels[c].setText(list.item(i));
         i++; c++;
     while(c < maxDisplay) {
         itemLabels[c].setVisible(true);
         itemLabels[c].setText("");
         c++;
     // clear input text field
     userInput.setText("");
    void showMessage(String Message) {
         messageLabel.setVisible(true); /* this line was not needed
                               in java1.0 */
     messageLabel.setText(Message);
    void showScrollbarMessage(String Message) {
         scrollbarLabel.setVisible(true); /* this line was not needed
                               in java1.0 */
     scrollbarLabel.setText(Message);
    public static void main(String args[])
     Frame f = new Frame("List Demo");
     ListDemo2 appletListDemo = new ListDemo2();
        f.setFont(new Font("Helvetica", Font.BOLD, 12));
        f.setSize(700, 300);
        f.setBackground(Color.green);
     f.add(appletListDemo);
     appletListDemo.init();
        f.setVisible(true);
}This code is called ListByVector.java and is used to generate the lists and then return the info back to ListDemo2.
import java.util.*;
public class ListByVector {
     private final int default_max_size = 4096;
     private int current_size;
     private int m;
     private Vector data;
     ListByVector(int initial_size) {
          data = new Vector();
          current_size = initial_size;
     public int sizeLimit(){ return default_max_size; }
     public int size(){ return current_size; }
     public String item(int which){ return (String)data.elementAt(which); }
     public void clearUp() {
          current_size = 0;
     public int insertAtEnd(String input_item) {     
          if(current_size < default_max_size) {
               data.insertElementAt(input_item, current_size);
               current_size++;
               return(current_size - 1);
          else {
               return -1;
     public int createRandomList(String string_size) {     
          int i;
          int j;
          if(!isIntString(string_size)) {
               return 0;
          else {
               Integer size = Integer.valueOf(string_size);
               current_size = size.intValue();
          Random R = new Random();
          for(i = 0; i<current_size; i++) {
               j = (int)(R.nextFloat()*current_size);
               data.insertElementAt(Integer.toString(j), i);
          return current_size;
     public int createOrderedList(String size_string) {
          int i;
          if(!isIntString(size_string)) {
               return 0;
          else {
               Integer size = Integer.valueOf(size_string);
               current_size = size.intValue();
          for(i = 0; i<current_size; i++) {
               data.insertElementAt(Integer.toString(i), i);
          return current_size;
/* As you can see for the delete method I have tried
several variations all giving the same problem, the one
which isn't commented out is the one which kind of
works i.e. when the delete button is pressed the correct
value appears for the number of duplicates that should
have been deleted but nothing visibly happens*/
     public int deleteMultiple() {
     /*     int i = 0;          
          while(i<data.size()) {
               int j;
               int k = 0;
               int l = k + 1;
               m = 0;
               for(j = 0; j<data.size()-1; j++) {
                    if(data.elementAt(k) == data.elementAt(l)) {
                         data.removeElementAt(l);
                    }//end if
                    else {          
                         m++;               
                         l++;
                    }//end else                    
               }//end for
               k++;
               i++;
          }//end while */
          m = 0;
          for(int i=0; i<data.size(); i++) {
               for(int j=data.size()-1; j>i; j--) {
                    if(data.elementAt(i).equals(data.elementAt(j))) {
                         data.removeElementAt(j);
                         m++;
     /*     int currIndex = 0;
          while(currIndex<data.size()) {
               int currIndex2;
               for(currIndex2 = currIndex + 1; currIndex2<data.size(); currIndex2++) {
                    if(data.elementAt(currIndex2).equals(data.elementAt(currIndex))) {
                         data.removeElementAt(currIndex2);
                         currIndex2++;
               currIndex++;
          return m;
     private boolean lessThan(String s1, String s2) {
          if(isIntString(s1) && isIntString(s2))
            return(Integer.parseInt(s1) < Integer.parseInt(s2));
          else
            return(s1.compareTo(s2) < 0);
     private boolean isIntString(String s) {
          int n = s.length();
          int i;
          if(n==0) return false;
          if(s.charAt(0) == '-') i = 1;
          else i = 0;
          if(i == n) return false;
          for(; i<n; i++) {
               if(s.charAt(i) < '0') return false;
               if(s.charAt(i) > '9') return false;
          return true;
}

Similar Messages

  • How to remove a value from a vector of vectors

    How can I remove a value from a vector inside another vector, say;
    Vector myvector= new Vector();
    Vector data= new Vector();
    myvector.addElement(rs.getString(1));
    myvector.addElement(rs.getString(2));
    myvector.addElement(rs.getString(3));
    data.addElement(myvector);
    I want to get an element in the Vector "myvector" at index 2.

    import java.util.*;
    public class Test {
      public static void main(String args[]) {
        Vector myvector= new Vector();
        Vector data= new Vector();
        myvector.addElement("Zero");
        myvector.addElement("One");
        myvector.addElement("Two");
        data.addElement(myvector);
        System.out.println("main vector initially contains:" + data);
        myvector.remove(1);
        System.out.println("main vector now contains:" + data);
    }Output:
    main vector initially contains:[[Zero, One, Two]]
    main vector now contains:[[Zero, Two]]
    Just to be sure I was correct in the first place. Perhaps you should have done likewise before continuing stick to your guns.

  • Need to compare values in two columns of one table against values in two columns in another table

    Hi, as the title reads, I'm looking for an approach that will allow me to compare values in two columns of one table against values in two columns in another table.
    Say, for instance, here are my tables:
    Table1:
    Server,Login
    ABCDEF,JOHN
    ABCDEF,JANE
    FEDCBA,SEAN
    FEDCBA,SHAWN
    Table2:
    Server,Login
    ABCDEF,JOHN
    ABCDEF,JANE
    FEDCBA,SHAWN
    In comparing the two tables, I'd like my query to report the rows in table1 NOT found in table2. In this case, it'll be the 3rd row of table one:
    Server,Login
    FEDCBA,SEAN
    Thanks.

    create table Table1([Server] varchar(50), Login varchar(50))
    Insert into Table1 values ('ABCDEF','JOHN'),('ABCDEF','JANE'),('FEDCBA','SEAN'),('FEDCBA','SHAWN')
    create table Table2([Server] varchar(50), Login varchar(50))
    Insert into Table2 values ('ABCDEF','JOHN'),('ABCDEF','JANE'), ('FEDCBA','SHAWN')
    select [Server] ,Login from Table1
    Except
    select [Server] ,Login from Table2
    select [Server] ,Login from Table1 t1
    where not exists(Select 1 from Table2 where t1.[Server] = t1.[Server] AND Login=t1.Login)
    drop table Table1,Table2

  • Required UDF for comparing values within same context

    I have to compare values within the same context.I am getting boolean values for that field.If all the values in the same context are true,then the result should be true .Otherwise false  should be passed.
    If input is-
    <context>                                  
    true
    false
    true
    <context>
    true
    true
    <context>
    Output should be as-
    <context>
    false
    <context>
    true
    <context>
    Please suggest how to acheive this?..its urgent

    Hi,
    Check with this UDF
    Src>UDF>target
    public void context1(String[] a,ResultList result,Container container)
        int k = 0;
        int arrayLength = a.length;
        if (arrayLength > 0)
            String firstElement = a[0];
            for (int i = 1; i < arrayLength; ++i)
                   if(!(a<i>.equalsIgnoreCase(firstElement)))
                     k = 0;
                     break;
                   else
                     k = 1;
    if(k == 1)
        result.addValue("true");
    else
        result.addValue("false");

  • Comparing elements inside a vector

    Hello,
    I am having a hard time understanding how to compare elements inside a vector. I have a vector of six strings and I want to compare the first element at index 0 with all other elements at positions 1-5. After that, compare the element at position 1 with elements at positions 2-5 and so on until all elements have been compared against each other.
    Can some one please advise me on how to achieve this?
    Thank you.

    joor_empire wrote:
    Thanks for replying. I tried using nested loops, but I keep getting array index out of bound error.Hmmm, then you're doing it wrong.
    For more information, you'll have to give us more info, such as your code (please use code tags when posting it though).

  • Comparing values in different tables

    Hi,
    I am trying to compare values in two different table fields, can someone advise me of the ABAP to do it.
    I need to find IHPA-PARNR(partner number) in table T527X-ORGEH(org unit number)
    Thanks,
    Alec

    OK now I'm confused:
    I put a breakpoint as follows:
    SELECT * FROM t527x INTO TABLE it_t527x.                        
    LOOP AT it_ihpa INTO wa_ihpa.                                   
    READ TABLE it_t527x INTO wa_t527x WITH KEY orgeh = wa_ihpa-parnr
    BINARY SEARCH.                                                  
    IF sy-subrc EQ 0.                                               
    BREAK-POINT.                                                    
    WRITE: wa_t527X-ORGTX TO ZORGUNITTEXT.                          
    ELSE.                                                           
    WRITE: 'Damn it' TO ZORGUNITTEXT.                               
    ENDIF.                                                          
    ENDLOOP.          
    I have the correct values in the correct fields but still SUBRC does not = 0
    WA_T527X-ORGTX                 Stockton - Front of House      
    ZORGUNITTEXT                   Damn it                        
    WA_t527X-ORGEH                 20008855                       
    WA_IHPA-parnr                  20008855                       
    Whats Wrong?
    Edited by: Alec Fletcher on Dec 19, 2008 1:50 PM

  • Comparable[] items, Comparable value

    how can I change this
    public static boolean search(Comparable[] items, Comparable value, int low, int high) {
    if (low > high) return false;
             int middle = (low + high) / 2;
             if (items[middle].equals(value)) return true;
             if (value.compareTo(items[middle]) < 0) {
                 // recursively search the left part of the array
                 return search(items,  value,  low, middle-1);
             else {
                 // recursively search the right part of the array
                 return search(items, value, middle+1, high);
    TO
    public static boolean binarySearch(int[] nums, int value, int low, int high) {
    }

    By simply changing the method signature and the code?

  • How to delete the values of a vector of map with some conditions?

    Hi Friends!
    I have three map<int, vector<int>>
    mainmap, m1, and m2.
    m1 contains;
    2=>9  16
    3=>11  16
    4=>13
    mainmap contains; (keys of m1 are selected out of keys of mainmap)
    1=>10  13  0  12  15
    2=>12  0  0  11  0
    3=>13  0  0  0  0
    4=>14  11  12  0  15
    m2 contains; (keys of m2 are the values of mainmap)
    11=>9  16
    12=>3  12
    13=>11
    14=>3  9  16
    15=>1  3  6  9  16
    I want to execute the following tasks;
    first, pointing key '2' from m1 and the correspondent vectors are selected from mainmap with same key '2' (12  0  0  11  0).
    second, out of the selected vector(keys of m2) are selected to compare the values of m2 and values of m1.
    here ;
    11=>9  16
    12=>3  12
    are selected.
    Out of these selected figure (11=>9; 12=>3  12) if the value (9, 16) are fully matched, that key '11' is selected.
    Suppose, in case the selected figure is (11=>9; 12=>3  12), that is partially matched as only 9 is available, then 16 is deleted from the value of 2 in m1, and select the key '11' from m2.
    Then, it continues up to key '4' in m1.
    Could anyone help me to solve this?

    Hi Friends!
    I have three map<int, vector<int>>
    mainmap, m1, and m2.
    m1 contains;
    2=>9  16
    3=>11  16
    4=>13
    mainmap contains; (keys of m1 are selected out of keys of mainmap)
    1=>10  13  0  12  15
    2=>12  0  0  11  0
    3=>13  0  0  0  0
    4=>14  11  12  0  15
    m2 contains; (keys of m2 are the values of mainmap)
    11=>9  16
    12=>3  12
    13=>11
    14=>3  9  16
    15=>1  3  6  9  16
    I want to execute the following tasks;
    first, pointing key '2' from m1 and the correspondent vectors are selected from mainmap with same key '2' (12  0  0  11  0).
    second, out of the selected vector(keys of m2) are selected to compare the values of m2 and values of m1.
    here ;
    11=>9  16
    12=>3  12
    are selected.
    Out of these selected figure (11=>9; 12=>3  12) if the value (9, 16) are fully matched, that key '11' is selected.
    Suppose, in case the selected figure is (11=>9; 12=>3  12), that is partially matched as only 9 is available, then 16 is deleted from the value of 2 in m1, and select the key '11' from m2.
    Then, it continues up to key '4' in m1.
    Could anyone help me to solve this?
    1. Did you mean
    "Out of these selected figure (11=>9 16; 12=>3  12) if the value (9, 16) are fully matched, that key '11' is selected."
    2. When you say fully matched or partially matched, do you mean just in key 2 of m1?
    3. What happens if there is no match?
    4. What does it mean to say that a key from m2 is "selected"? What happens to keys that are or are not selected?
    5. If the result of this exercise is a change in the three maps, you should at least tell us what that change is. If the result is some other data structure, then tell us what it is.
    David Wilkinson | Visual C++ MVP

  • Getting two values from a vector

    Hello
    I have a string which when i print it out i get these values.
    hello
    hello
    hello
    hello
    hello
    hello
    hello
    bye
    bye
    bye
    and i want to be able to print out just one of each word
    hello
    ben
    How can i do this with using a vector?
    thanks
    bobby

    Something like this:
    Vector bigVectorOStuff; // declared elsewhere, this contains your Strings
    Vector uniqueEntries = new Vector();
    Enumeration enum = bigVectorOStuff.elements();
    String entry = null;
    while (enum.hasMoreElements())
        entry = (String)enum.nextElement();
        if (!uniqueEntries.contains(entry))
             uniqueEntries.add(entry);
    }That is, loop through the original Vector, getting each element out one at a time. Check to see if this element is in the other Vector, and if not, add it.

  • How can i display the values in the vector in a jsp using jstl

    in a task i am recieving a vector in a jsp... how can i display those vector values in the jsp using jstl.... plz help me
    thanks in advance

    <%
    here you got vector say; v
    pagecontext.setAttribute("varname",v);
    %>
    <c:forEach var="i" items="${varname}">
    <c:out value="${i}">
    </c:forEach>

  • How to compare values in table control

    Hi Experts,
    How to compare two values of a field in table control. Like the frist row of feld1 with the second row of field1.
    because when ever two values are same i need to display error message that we are entring duplicate entry.
    i have been tring for a very log time but not getting any solution for this.
    Thanks and Regards,
    Ashwin.

    you need to write in code for this..
    A possible solution is given below..
    Suppose your internal table fields are col1 and col2.
    in the loop .....endloop of yout internal table in your PAI..there will be  following(if your table control is made using wizard. otherwise you might have to add it..
    loop at itab.
    chain.
    field col1.
    field col2.
    "some module
    endchain.
    endloop.
    now make changes as shown to the above code..
    loop at itab.
    chain.
    field wa-col1.
    field wa-col2.
    module table_modify on chain-request.
    endchain.
    now in your program add module table modify.
    module table_modify input.
    read table itab with key col1(which shud be unique) = wa-col1 transporting no-fields.
    if sy-subrc = 0. " there exists another record with the same value
    message e001(your message class).
    endif.
    endmodule.
    i guess that shud work. get back if it dosnt.
    regards
    Suzie

  • How to compare value of two Combo Box

    I've two Combo Box(cbFirst & cbSecond). I want to compare the value that has been selected by the user and based on the result, output is displayed. In both Combo Box I've provided the value.
    Here is my code:
    var a:Number;
    var b:Number;
    function First(evt:Event):void{
        a = evt.target.value;
        trace(a);   
    cbFirst.addEventListener(Event.CHANGE, First);
    function Second(evt:Event):void{
        b = evt.target.value;
        trace(b);
    cbSecond.addEventListener(Event.CHANGE, Second);
    If (a > b){
         trace("a is greater")
    else
         trace(b is greater);
    The trace statement inside the functions are working fine and the correct value of a & b is printed. But the comparison in the if statement doesn't seem to work. Could you please help me out.

    there's a typo.  fix it or remove it:
    var a:Number;
    var b:Number;
    function First(evt:Event):void{
        a = evt.target.value;
    trace(a);
       compareF();
    cbFirst.addEventListener(Event.CHANGE, First);
    function Second(evt:Event):void{
        b = evt.target.value;
        trace(b);
    compareF()
    cbSecond.addEventListener(Event.CHANGE, Second);
    function compareF(){
    If (a > b){
         trace("a is greater")
    else
         trace(b is greater);

  • Passing values in a vector list as bind variables in sql query.

    Hi,
    I have a vector list containing values 12,13,14.
    vector<string> v;
    v has values 12,13 and 14.
    Here the number of values in vector list are not fixed.
    I want to pass these values as bind variables to sql query.
    Can anyone suggest me how to do this.
    Thanks in advance!!

    Ah, the it's the classic 'Varying In-List' again
    See:
    The Tom Kyte Blog: Varying in lists...
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:110612348061 (started more than a decade ago, so scroll down for more recent examples)

  • Compare element in a vector

    hi,
    I want to compare the float no in a vector e.g. [{0.2},{0.55}];
    but I cannot just compare the 2 using x.elementAt(i) becoz this return object so
    i do ix.elementAt(i) nstanceOf float but it pops up error,
    but I am actually doing object instance of float, I am wondering where it was wrong
    for(int i=1;i<x.size(); i++){
    if(x.elementAt(i) instanceOf float){
    if( x.elementAt(i)< x.elementAt(i-1)){
    mean_dist.addElement(x.elementAt(i));
    mean_dist.toString();
    System.out.println("train data: "+ mean_dist);
    anyone can give me idea
    many thx

    yep, sure thing, when you use Vector.elementAt(index) it returns an Object, not a Float
    but... you KNOW its a Float cos thats what you put there! ok?
    Vector has to return Object as when the class was written there was no idea what you would use it for and Object is the general class that coveres just about everything..
    what you need to do is "cast" to Float, that is saying,
    "ok you dont know its a Float, but I do ( I hope) and I want you to deal with it as a Float"
    the way you do this is Float gimme=(Float)myVector.elementAt(index);this tell the compiler that you expect a Float and should deal with the return as a Float
    the compiler will do its best to use what it gets as a Float, but if it cant (ie if you put something that isnt a Float in myVector at (index)) then it will generate a ClassCastException
    you dont HAVE to catch this, but you may if you want

  • How to compare values in resultset

    i am having problem in comparing result set values. Actually my store proc returns me the following resultset:
    Month | Year | Deductible | Troop | TDC | ReasonCode
    ------------|-----------|-----------------|------------|-------------|--------------------------
    January | 2008 | $100.0 | $0.0 | $0.0 | 1
    ------------|-----------|-----------------|------------|--------------|--------------------------
    January | 2008 | $0.0 | $10.0 | $0.0 | 1
    ------------|-----------|---------------- |-------------|-------------|-------------------------
    January | 2008 | $0.0 | $0.0 | $20.0 | 1
    ------------|-----------|-----------------|-------------|-------------|-------------------------
    March | 2008 | $150.0 | $0.0 | $0.0 | 2
    ------------|-----------|-----------------|-------------|-------------|--------------------------
    March | 2008 | $0.0 | $15.0 | $0.0 | 2
    ------------|-----------|-----------------|-------------|-------------|-------------------------
    March | 2008 | $0.0 | $0.0 | $30.0 | 2
    i will compare month and year fields. i.e if year is same the compare month and if month is same (e.g. January) the first three row of the above table will be clubbed in one row i.e.
    Month | Year | Deductible | Troop | TDC | ReasonCode
    ------------|-----------|-----------------|------------|--------------|--------------------------
    January | 2008 | $100.0 | $10.0 | $20.0 | 1
    how can i do it in my result set?

    Learn SQL
    "Select Month, Year, SUM(Deductible), SUM(Troop), SUM(TDC), ReasonCode from table Group By Month, Year, ReasonCode"Otherwise, loop through the resultset and compare the fields you want to compare using .equals() and sum the values yourself (of course).

Maybe you are looking for

  • On-premise SharePoint 2013 and SkyDrive Pro Sync Issue

    Hi all, I'm not sure if this is the correct forum between SharePoint and SkyDrive as the issue is related to an update on SkyDrive Pro. premise SharePoint 2013 installation (migrated from 2010) and Office 2013 installed. SharePoint is patched up to t

  • Unable to pass comma separated values for in clause

    I have the following query : for :P_LEG_NUM Parameter when i am passing values like 1,2,5 as string type i am getting invalid number error... I have defined in clause for it but still it does not work.. For individual values like 2, etc it works... h

  • Could not convert Word 2007 form

    I'm running Acrobat 11 (up to date). When I try and convert a Word 2007 form to an Acrobat form, I get the message: Acrobat could not create new PDF form"

  • Is the NVIDIA processor in the 2014 MacBook Pro helpful for Photoshop?

    I am in the market for a 15" MacBook Pro with Retina Display. I am trying to decide between a few different models. Is the NVIDIA 750M Graphics Processor going to make any difference in my life, positive or negative? I use InDesign and Photoshop quit

  • Text don't show in email received

    When I receive email on my iCloud account, on a PC, the text don't show ?