MySQL 过程导致语法错误

MySQL procedure results in a syntax error

这是我的 MySQL 程序。执行此操作时出现错误。

  DELIMITER //
  CREATE PROCEDURE GET_ORDER_HISTORY_LIST(IN distid int)
  BEGIN
  SELECT 
  ort.order_id,
  ort.transaction_id,
  ort.user_id,
  ort.transaction_date,
  ort.insert_by,
  ort.organization_id,
  odt.course_id,
  count(odt.quantity),
  ct.course_name,
  ct.course_code
  FROM cdp_order_master as ort
  JOIN cdp_order_detail as odt ON odt.order_id = ort.order_id 
  JOIN cdp_course as ct ON ct.course_id = odt.course_id
  WHERE ort.user_id = distid
  GROUP BY ort.order_id
  END //
 DELIMITER ;

错误是

 #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'END' at line 19
DELIMITER //
  CREATE PROCEDURE GET_ORDER_HISTORY_LIST(IN distid int)
  BEGIN
  SELECT 
  ort.order_id,
  ort.transaction_id,
  ort.user_id,
  ort.transaction_date,
  ort.insert_by,
  ort.organization_id,
  odt.course_id,
  count(odt.quantity),
  ct.course_name,
  ct.course_code
  FROM cdp_order_master as ort
  JOIN cdp_order_detail as odt ON odt.order_id = ort.order_id 
  JOIN cdp_course as ct ON ct.course_id = odt.course_id
  WHERE ort.user_id = distid
  GROUP BY ort.order_id; //I had made change at this line.
  END //
 DELIMITER ;

您可以试试上面的查询。

这里是SQL Fiddle.