1

I am using latest version of Sqlite-net-pcl Nuget by Frank A. Krueger .

I need to get the maximum value of the column AccountNumber from the table AccountMasterModel.

I tried this

 public Task<List<int>> GetAccountMaxAsync()
        {
                return database.QueryAsync<int>("SELECT Max(AccountNumber) FROM [AccountMasterModel] ");
        }

I call this kmethod as follows

List<int> max = new List<int>();
 max = await App.Database.GetAccountMaxAsync();

The code executes successfully for me. Even I have the values 23 and 54 in the AccountNumber Column I always get the value 0 in max. Actually I need to 54 in max but I get only 0. Need a help here.

mohammed mazin
  • 445
  • 3
  • 15

1 Answers1

4
var max = await conn.ExecuteScalarAsync<int>("SELECT Max(AccountNumber) FROM [AccountMasterModel] ", null);
Jason
  • 86,222
  • 15
  • 131
  • 146
  • Thank you for your response. I changed the query as shown and I got the result . `("select * from [AccountMasterModel] where [AccountNumber]=(select max([AccountNumber]) from [AccountMasterModel]) ")` – mohammed mazin Jul 14 '18 at 00:11