SQlite Sum RRS feed

  • Question

  • User389856 posted

    I'm trying to calculate the sum total of a table column. I've tried using:

    public Task GetFruitTotalForDayAsync(string day) { return _database.ExecuteScalarAsync("SELECT SUM(Fruit) FROM Order WHERE Day = ?", day); }

    but I get a syntax error near Order.

    Sunday, October 20, 2019 5:53 AM

All replies

  • User378095 posted

    @antmck2019 Order is a keyword, if you want to use it as a table name, you can add []. SELECT SUM(Fruit) FROM [Order] WHERE Day = ?

    Wednesday, October 23, 2019 1:06 AM