0

My query is giving me the sum of col_balance but I want the last inserted COL_BALANCE value by a particular (missing word). It must be something like:

select COL_BALANCE  from TABLE_NAME2  where name =(select col_bal from query where count is count -1 )

String selectQuery = " SELECT "+"sum(" + COL_BALANCE + ")"+ " FROM " + TABLE_NAME2  +  " WHERE " + COL_CUST_NAME + "= '" + name + "';";
Al Lelopath
  • 6,448
  • 13
  • 82
  • 139
bipin
  • 1,091
  • 4
  • 12
  • 30
  • How do you identify the row that is the last? Do you have a timestamp or a an increasing ID? – CL. Mar 17 '16 at 15:35
  • The solution here: http://stackoverflow.com/questions/9902394/how-to-get-last-record-from-sqlite tells how to get the last record from a table. Is this what you need? – Al Lelopath Mar 17 '16 at 15:49

1 Answers1

-1

SQLite

This is available using the SQLite last_insert_rowid() function:

"The last_insert_rowid() function returns the ROWID of the last row insert from the database connection which invoked the function. The last_insert_rowid() SQL function is a wrapper around the sqlite3_last_insert_rowid() C/C++ interface function."

pank_94
  • 13
  • 7