call previous row in table RRS feed

  • Question

  • User-2060576634 posted

    hi. .

    is there a way to call the previous row of a query in a database table?

    Wednesday, June 3, 2015 7:48 AM


  • User1526116210 posted

    Assuming that all of the months are sequential you could do something like this.

    int currentMonth = returnedData.Month;
    var requiredData = db.Table.FirstOrDefault(m => m.Month == currentMonth -1);

    I haven't used SQL in a while so I've represented what your code would look like with EF.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, June 4, 2015 4:45 AM