How to select records without duplicate on just one field Sqlite Android
<p>I have a table with columns like this:</p>

<pre><code>+--------+----+--------+---------------+------- +-------+---------+  
| DATE   | ID | Name   | Cattle Type   |  Liter | Shift | Payment |
+--------+----+--------+---------------+------- +-------+---------+  
</code></pre>

<p>And Data is like this</p>

<pre><code>9-9-2016 |  01  | Abhi  | Cow | 2 | AM | 50 |
9-9-2016 |  02  | Ram   | Buff | 1 | AM | 25 |
9-9-2016 |  01  | Abhi  | Buff | 2 | PM | 50 |
9-9-2016 |  01  | Abhi  | Cow | 2 | PM | 50 |
</code></pre>

<p>I am fetching all the data by passing date in the database function 
example :-</p>

<pre><code>databaseObject.getAlldata(String From_date, StringTo_date)
</code></pre>

<p>After that i  get all the values from my database and i store it to a list.</p>

<p>I need to have id without any duplicate. Actually I need their id and Cattle type,liter,payment What is the best Sqlite command to make this? </p>

<p>My desired result is something like this:</p>

<pre><code>ID : 1 
Cow  = 4.00 Litre  Rs 100 
Buff = 2.00 Litre  Rs 50
Total = Rs 150 

ID : 2
Cow  = 0.00 Litre  Rs 0.0 
Buff = 1.00 Litre  Rs 25
Total = Rs 25
</code></pre>

<p>My code is :  </p>

<pre><code>list1 = db.getAllMilkCollection(start, end);

try {
    for( i = 0; i &lt; list1.size(); i++) {
        CattleTypeCowTotal = 0;
        CattleTypeBuffTotal = 0 ;
        String id = list1.get(i).member_code;

        list2 = db.getAllDataOfPaymentRegister(start,end,id);

        for( j = 0; j &lt; list2.size(); j++) {
            String member_name = list2.get(j).member_name;  
            String Cattle_type = list2.get(j).cattle_type;

            if(Cattle_type.equalsIgnoreCase("Cow")){
                String amount = list2.get(j).amount.trim();   
                if(amount!=null){
                    CattleTypeCowTotal += Float.parseFloat(amount);
                }
            }

            if(Cattle_type.equalsIgnoreCase("buff")){
                String amount = list2.get(j).amount.trim();   
                if(amount != null){
                    CattleTypeBuffTotal  += Float.parseFloat(amount);
                }
            }
        }
        System.out.println("xxxxxxxxxxxxxxxxxxxx");
    }

} catch (Exception e) {
    Log.e("Error", ""+e);
}                       
</code></pre>

<p>Thanks in advance :) :)</p>