This is my procedure:
DELIMITER $$
CREATE PROCEDURE sp_test_final6()
BEGIN
INSERT INTO `chef_ratings`(`chef_id`,`avg_total_no_votes`,`avg_total_rating`,`no_of_votes`,`avg_rating`)
SELECT `chef_id`,(SELECT count(chef_id) FROM rates)/( SELECT count(DISTINCT chef_id) FROM rates),
(( SELECT sum((`question_1` + `question_2` +`question_3` )/3) FROM rates ) / ( SELECT count(chef_id) FROM rates)),
( SELECT count(chef_id) FROM rates ),avg((`question_1`+`question_2`+`question_3`)/3)
FROM rates GROUP BY `chef_id`;
END $$
DELIMITER ;
I'm getting error :
#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 'PROCEDURE sp_test_final6()
BEGIN
INSERT INTO `chef_ratings`( `chef_id`, `avg_t' at line 1
Any idea why it is failing?
Edited: It works fine in mysql version 5.5 but in Server version: 4.1.22 it is giving this problem. How we can fix without upgrading?