DECLARE totalCalls CURSORFORSelectcount(flow_step) as total, DATE(operate_date) as dat, office, recruit, main from v_student whereDATE(operate_date) >= DATE(startDate) AndDATE(operate_date) <= DATE(endDate) groupbyDATE(operate_date), office, recruit, main orderbyDATE(operate_date);
DECLARE qualCalls CURSORFORSelectcount(flow_step) as qual, DATE(operate_date) as dat, office, recruit, main from v_student where flow_step <> ‘NQ’AndDATE(operate_date) >= DATE(startDate) andDATE(operate_date) <= DATE(endDate) groupbyDATE(operate_date), office, recruit, main orderbyDATE(operate_date);
DECLARE schedCalls CURSORFORSelectcount(flow_step) as sched, DATE(operate_date) as dat, office, recruit, main from v_student where flow_step = ‘Assessment Scheduled’AndDATE(operate_date) >= DATE(startDate) andDATE(operate_date) <= DATE(endDate) groupbyDATE(operate_date), office, recruit, main orderbyDATE(operate_date);
DECLARE totalSched CURSORFORSelectcount(flow_step) as sched, officeTime, DATE(vco_date) as dat, assessor, office, recruit, main from v_student where flow_step = ‘Assessment Scheduled’AndDATE(vco_date) >= DATE(startDate) AndDATE(vco_date) <= DATE(endDate) groupby officeTime, DATE(vco_date), assessor, office, main orderbyDATE(vco_date);
DECLARE showSched CURSORFORSelectcount(shows) as shows, officeTime, DATE(vco_date) as dat, assessor, office, recruit, main from v_student where shows isnotnullAnd flow_step = ‘Assessment Scheduled’AndDATE(vco_date) >= DATE(startDate) AndDATE(vco_date) <= DATE(endDate) groupby officeTime, DATE(vco_date), assessor, office, main orderbyDATE(vco_date);
DECLARE qualSched CURSORFORSelectcount(qual) as quals, officeTime, DATE(vco_date) as dat, assessor, office, recruit, main from v_student where qual isnotnullAnd flow_step = ‘Assessment Scheduled’AndDATE(vco_date) >= DATE(startDate) AndDATE(vco_date) <= DATE(endDate) groupby officeTime, DATE(vco_date), assessor, office, main orderbyDATE(vco_date);
DECLARE keptSched CURSORFORSelectcount(kept) as kepts, officeTime, DATE(vco_date) as dat, assessor, office, recruit, main from v_student where kept isnotnullAnd flow_step = ‘Assessment Scheduled’AndDATE(vco_date) >= DATE(startDate) AndDATE(vco_date) <= DATE(endDate) groupby officeTime, DATE(vco_date), assessor, office, main orderbyDATE(vco_date);
DECLARE acceptSched CURSORFORSelectcount(accept) as accepts, officeTime, DATE(vco_date) as dat, assessor, office, recruit, main from v_student where accept isnotnullAnd flow_step = ‘Assessment Scheduled’AndDATE(vco_date) >= DATE(startDate) AndDATE(vco_date) <= DATE(endDate) groupby officeTime, DATE(vco_date), assessor, office, main orderbyDATE(vco_date);
nbsp;
[sql] view plaincopy
/* 定义光标结束标志 */
DECLARECONTINUE HANDLER FORNOT FOUND SET _cursor_flag = -1;
DELETEFROM STAT_TEMP;
COMMIT;
OPEN totalCalls; /*打开光标*/
LOOP_totalCalls:LOOP /* 循环声明 */
FETCH totalCalls INTO total, dat, offic, recrui, ma;