Can you provide a very simple SQL example of how to create a \"count\" or \"order\" field that would auto-increment, but restart after every change in a different field? In
Instead of storing Order in the table, consider adding it to a view. You can select from the view instead of the table when you need it.
Order
The view could use row_number() to calculate the order, like:
row_number()
select row_number() over (partition by Meal order by Time) , * from YourTable
Example at SE Data.