1

我有一个存储过程,我想GROUP BY在这样的FOREACH语句中使用:

FOREACH SELECT a.task_code, a.task_name, MAX(a.cand_num)
          FROM (SELECT DISTINCT a.task_code, a.task_name, 0 as cand_num   
                  INTO ll_task_code, ls_task_name, ll_cand_num  
                ...........
                ...........
               ) AS u
         GROUP BY a.task_code, a.task_name
    RETURN ll_task_code, ls_task_name, ll_cand_num WITH RESUME;
END FOREACH;

但我得到一个语法错误into ll_task_code, ls_task_name, ll_cand_num

怎么GROUP BYFOREACH

4

1 回答 1

2

into外面去试试。

FOREACH SELECT a.task_code, a.task_name, MAX(a.cand_num)
          INTO ll_task_code, ls_task_name, ll_cand_num  
          FROM (SELECT DISTINCT a.task_code, a.task_name, 0 as cand_num   
                ...........
                ...........
               ) AS u
         GROUP BY a.task_code, a.task_name
    RETURN ll_task_code, ls_task_name, ll_cand_num WITH RESUME;
END FOREACH;
于 2013-02-03T10:58:30.557 回答