
SELECT meals
REPLACE ALL ordered WITH 0, eaten WITH 0

SELECT orders
SCAN
    SCATTER FIELDS meal, ordered, eaten MEMVAR 
    SELECT meals
    REPLACE FOR id = m.meal ordered WITH ordered + m.ordered, eaten WITH eaten + m.eaten
ENDSCAN 

SELECT meals
SET FILTER TO ordered # 0 .or. eaten # 0
INDEX on date + STR(canteen,3) + STR(course_ord) + STR(number) TAG dacaconu
DO pr_report WITH "stravovani_meals"
