Group by and account with sqlite in android

I have a sqlite table in my Android application and I need to calculate how many elements have the same date. Here is a simple table layout:

col1 | col2 | date_item |

xx | xx | 2012-04-12 |

yy | er | 2012-05-12 |

.........

I believe that to count the number of rows having the same date, I need to execute a query using a group. The problem is that if I do the following:

Cursor cursor = db.query("table_name", new String[] {"date_item"}, null, null, "date_item", null, null);

and I return cursor.getColumnCount();. I get only 1 column. So how can I do this to have 2 columns (one for date_item and one for count )?

Thanks Mattia

+3
source share

All Articles