3

Possible Duplicate:
How do i order my SQLITE database in descending order, for an android app?

I've the following table where i'd like to select the contents of the table but order by the C_TAG_SCAN_TIME field DESC.

public static final String C_ID = BaseColumns._ID; // special for id internally in system
    public static final String C_TYPE = "type";
    public static final String C_COMPANY_ID = "companyid";
    public static final String C_PERSON_ID = "person";
    public static final String C_NAME = "name";
    public static final String C_TAG_ID = "tagid";
    public static final String C_STATUS = "status";
    public static final String C_TAG_SCAN_TIME = "tagscantime";
    public static final String C_TAG_SENTSERVER_TIME = "tagsentservertime";
    public static final String C_TRANSACTIONS_LATITUDE = "transactionslatitude";
    public static final String C_TRANSACTIONS_LONGITUDE = "transactionslongitude";

.

This is my query to select everything from the table TRANSACTIONS.

return db.query(DBHelper.TABLETRANSACTIONS, null, null, null, null, null, null);

My question is how can i change the query to order descendingly on the C_TAG_SCAN_TIME column?

Community
  • 1
  • 1
turtleboy
  • 8,210
  • 27
  • 100
  • 199

1 Answers1

8

Please try this...

return db.query(DBHelper.TABLETRANSACTIONS, null, null, null, null, null, C_TAG_SCAN_TIME + " DESC");
Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94
Nikhil
  • 16,194
  • 20
  • 64
  • 81